Skip to content

Commit

Permalink
Merge pull request #1485 from rstudio/Popen-on-windows-revisited
Browse files Browse the repository at this point in the history
hand-roll wrapper for `Popen.__init__`
  • Loading branch information
t-kalinowski authored Sep 20, 2023
2 parents 9cc31aa + f2e06f0 commit d5b014b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: reticulate
Type: Package
Title: Interface to 'Python'
Version: 1.32.0.9001
Version: 1.32.0.9002
Authors@R: c(
person("Tomasz", "Kalinowski", role = c("ctb", "cre"),
email = "tomasz@posit.co"),
Expand Down
14 changes: 11 additions & 3 deletions inst/python/rpytools/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@


def patch_subprocess_Popen():
from subprocess import Popen, DEVNULL
from functools import partialmethod
from functools import wraps
import subprocess

Popen.__init__ = partialmethod(Popen.__init__, stdin=DEVNULL)
og_Popen__init__ = subprocess.Popen.__init__

@wraps(subprocess.Popen.__init__)
def __init__(self, *args, **kwargs):
if kwargs.get("stdin") is None:
kwargs["stdin"] = subprocess.DEVNULL
return og_Popen__init__(self, *args, **kwargs)

subprocess.Popen.__init__ = __init__

0 comments on commit d5b014b

Please sign in to comment.