From 2dc7dfe9300bccf1eaf8e13db606847171147bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lozier?= Date: Tue, 9 Jan 2024 16:57:41 -0500 Subject: [PATCH] Fix issue with subprocess.Popen not producing any output --- Src/StdLib/Lib/subprocess.py | 2 +- Tests/test_regressions.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Src/StdLib/Lib/subprocess.py b/Src/StdLib/Lib/subprocess.py index 4a0d1e87f..ea6b472a9 100644 --- a/Src/StdLib/Lib/subprocess.py +++ b/Src/StdLib/Lib/subprocess.py @@ -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): diff --git a/Tests/test_regressions.py b/Tests/test_regressions.py index 4ac3ff57d..b9ab08ab9 100644 --- a/Tests/test_regressions.py +++ b/Tests/test_regressions.py @@ -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__)