Skip to content

Commit

Permalink
Fix issue with subprocess.Popen not producing any output
Browse files Browse the repository at this point in the history
  • Loading branch information
slozier committed Jan 9, 2024
1 parent 6a3f6a0 commit 2dc7dfe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Src/StdLib/Lib/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ def _get_handles(self, stdin, stdout, stderr):
errread, errwrite = _winapi.CreatePipe(None, 0)
errread, errwrite = Handle(errread), Handle(errwrite)
elif stderr == STDOUT:
errwrite = c2pwrite
errwrite = int(c2pwrite) # ironpython: cast to int to prevent closing in _make_inheritable
elif stderr == DEVNULL:
errwrite = msvcrt.get_osfhandle(self._get_devnull())
elif isinstance(stderr, int):
Expand Down
11 changes: 11 additions & 0 deletions Tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1710,4 +1710,15 @@ def test_ipy3_gh1649(self):
def test_map_type_int(self):
self.assertEqual(list(map(type, [0])), [type(0)])

def test_ipy3_gh1135(self):
# https://github.com/IronLanguages/ironpython3/issues/1135
import sys
import subprocess
with subprocess.Popen([sys.executable, '-c', 'print("aaa", end="")'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as p:
out, err = p.communicate()

# ensure out is the expected value and not empty
self.assertEqual(out, b"aaa")


run_test(__name__)

0 comments on commit 2dc7dfe

Please sign in to comment.