Richard Oudkerk <[email protected]> added the comment:
A program which depends on the old behaviour would be broken on a
non-refcounted implementation of Python, so I would be inclined to say "won't
fix".
However, I think the following patch would restore the old behaviour
diff -r a970054a93fb Lib/os.py
--- a/Lib/os.py Mon Jul 16 18:30:03 2012 +0100
+++ b/Lib/os.py Mon Jul 23 19:12:38 2012 +0100
@@ -1004,6 +1004,13 @@
# Helper for popen() -- a proxy for a file whose close waits for the process
class _wrap_close:
def __init__(self, stream, proc):
+ # proc should be waited on when stream is garbage collected
+ import weakref
+ def callback(wr):
+ proc._weakref = None # break ref cycle
+ proc.wait()
+ proc._weakref = weakref.ref(stream, callback)
+ proc.stdin = proc.stdout = None # proc must not keep stream alive
self._stream = stream
self._proc = proc
def close(self):
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15408>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com