[pypy-commit] pypy py3k: apply workaround from default: Don't rely on reference counting to close the

pjenvey noreply at buildbot.pypy.org
Fri Apr 19 03:13:20 CEST 2013


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r63498:7737ba1bb77c
Date: 2013-04-18 18:11 -0700
http://bitbucket.org/pypy/pypy/changeset/7737ba1bb77c/

Log:	apply workaround from default: Don't rely on reference counting to
	close the non-heritable handle. This avoids a deadlock on Windows,
	when stdout=PIPE.

diff --git a/lib-python/3/subprocess.py b/lib-python/3/subprocess.py
--- a/lib-python/3/subprocess.py
+++ b/lib-python/3/subprocess.py
@@ -886,10 +886,14 @@
 
         def _make_inheritable(self, handle):
             """Return a duplicate of handle, which is inheritable"""
-            return _subprocess.DuplicateHandle(_subprocess.GetCurrentProcess(),
+            dupl = _subprocess.DuplicateHandle(_subprocess.GetCurrentProcess(),
                                 handle, _subprocess.GetCurrentProcess(), 0, 1,
                                 _subprocess.DUPLICATE_SAME_ACCESS)
-
+            # If the initial handle was obtained with CreatePipe, close
+            # it
+            if not isinstance(handle, int):
+                handle.Close()
+            return dupl
 
         def _find_w9xpopen(self):
             """Find and return absolut path to w9xpopen.exe"""


More information about the pypy-commit mailing list