]> granicus.if.org Git - python/commitdiff
Refactor test_preexec_errpipe to not create an uncollectable reference cycle.
authorGregory P. Smith <greg@krypto.org>
Sun, 11 Nov 2012 18:12:40 +0000 (10:12 -0800)
committerGregory P. Smith <greg@krypto.org>
Sun, 11 Nov 2012 18:12:40 +0000 (10:12 -0800)
1  2 
Lib/test/test_subprocess.py

index e502618219fcfc17d745e485b90fd7865ed79c0d,b0cd63c8f2508eab17c25f5b9bb2222282028514..d18784caa3dc5c8e7957c12772563d05851652e3
@@@ -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)