From: Gregory P. Smith Date: Sun, 11 Nov 2012 18:12:40 +0000 (-0800) Subject: Refactor test_preexec_errpipe to not create an uncollectable reference cycle. X-Git-Tag: v3.4.0a1~2029^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65ee6ece2d000e716bf1dcbf3bfc74c32ceba4c8;p=python Refactor test_preexec_errpipe to not create an uncollectable reference cycle. --- 65ee6ece2d000e716bf1dcbf3bfc74c32ceba4c8 diff --cc Lib/test/test_subprocess.py index e502618219,b0cd63c8f2..d18784caa3 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@@ -1221,10 -1213,16 +1213,17 @@@ class POSIXProcessTestCase(BaseTestCase finally: map(os.close, devzero_fds) - p._execute_child = _test_fds_execute_child_wrapper + @unittest.skipIf(not os.path.exists("/dev/zero"), "/dev/zero required.") + def test_preexec_errpipe_does_not_double_close_pipes(self): + """Issue16140: Don't double close pipes on preexec error.""" + + def raise_it(): - raise RuntimeError("force the _execute_child() errpipe_data path.") ++ raise subprocess.SubprocessError( ++ "force the _execute_child() errpipe_data path.") - with self.assertRaises(RuntimeError): + with self.assertRaises(subprocess.SubprocessError): - p.RealPopen([sys.executable, "-c", "pass"], + self._TestExecuteChildPopen( + self, [sys.executable, "-c", "pass"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=raise_it)