cpython: 734da14489c1 (original) (raw)
Mercurial > cpython
changeset 89099:734da14489c1 2.7
issue12085: Use more Pythonic way to check _child_created. _active shouldn't be cached, it set to None on shutdown. [#12085]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Mon, 10 Feb 2014 19:19:53 +0200 |
parents | 6b10943a5916 |
children | 3a7638baf511 |
files | Lib/subprocess.py |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-)[+] [-] Lib/subprocess.py 9 |
line wrap: on
line diff
--- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -645,6 +645,8 @@ def list2cmdline(seq): class Popen(object):
+ def init(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, @@ -653,7 +655,6 @@ class Popen(object): """Create new Popen instance.""" _cleanup()
self._child_created = False[](#l1.16) if not isinstance(bufsize, (int, long)):[](#l1.17) raise TypeError("bufsize must be an integer")[](#l1.18)
@@ -750,11 +751,11 @@ class Popen(object): return data
- def del(self, _maxint=sys.maxint): # If init hasn't had a chance to execute (e.g. if it # was passed an undeclared keyword argument), we don't # have a _child_created attribute at all.
if not getattr(self, '_child_created', False):[](#l1.29)
if not self._child_created:[](#l1.30) # We didn't get to successfully create a child process.[](#l1.31) return[](#l1.32) # In case the child hasn't been waited on, check if it's done.[](#l1.33)
@@ -1330,7 +1331,7 @@ class Popen(object): _WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED, _WEXITSTATUS=os.WEXITSTATUS): # This method is called (indirectly) by del, so it cannot
# refer to anything outside of its local scope."""[](#l1.38)
# refer to anything outside of its local scope.[](#l1.39) if _WIFSIGNALED(sts):[](#l1.40) self.returncode = -_WTERMSIG(sts)[](#l1.41) elif _WIFEXITED(sts):[](#l1.42)