cpython: 0f2714e49583 (original) (raw)
Mercurial > cpython
changeset 70554:0f2714e49583 3.2
Close #12085: Fix an attribute error in subprocess.Popen destructor if the constructor has failed, e.g. because of an undeclared keyword argument. Patch written by Oleg Oshmyan. [#12085]
Victor Stinner victor.stinner@haypocalc.com | |
---|---|
date | Wed, 01 Jun 2011 00:57:47 +0200 |
parents | 2a313ceaf17c |
children | 71dfd8cf4bf5 f2f74b8d6767 |
files | Lib/subprocess.py Lib/test/test_subprocess.py Misc/ACKS Misc/NEWS |
diffstat | 4 files changed, 19 insertions(+), 1 deletions(-)[+] [-] Lib/subprocess.py 5 Lib/test/test_subprocess.py 10 Misc/ACKS 1 Misc/NEWS 4 |
line wrap: on
line diff
--- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -768,7 +768,10 @@ class Popen(object): self.wait() def del(self, _maxsize=sys.maxsize, _active=_active):
if not self._child_created:[](#l1.7)
# If __init__ hasn't had a chance to execute (e.g. if it[](#l1.8)
# was passed an undeclared keyword argument), we don't[](#l1.9)
# have a _child_created attribute at all.[](#l1.10)
if not getattr(self, '_child_created', False):[](#l1.11) # We didn't get to successfully create a child process.[](#l1.12) return[](#l1.13) # In case the child hasn't been waited on, check if it's done.[](#l1.14)
--- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -121,6 +121,16 @@ class ProcessTestCase(BaseTestCase): env=newenv) self.assertEqual(rc, 1)
- def test_invalid_args(self):
# Popen() called with invalid arguments should raise TypeError[](#l2.8)
# but Popen.__del__ should not complain (issue #12085)[](#l2.9)
with support.captured_stderr() as s:[](#l2.10)
self.assertRaises(TypeError, subprocess.Popen, invalid_arg_name=1)[](#l2.11)
argcount = subprocess.Popen.__init__.__code__.co_argcount[](#l2.12)
too_many_args = [0] * (argcount + 1)[](#l2.13)
self.assertRaises(TypeError, subprocess.Popen, *too_many_args)[](#l2.14)
self.assertEqual(s.getvalue(), '')[](#l2.15)
+ def test_stdin_none(self): # .stdin is None when not redirected p = subprocess.Popen([sys.executable, "-c", 'print("banana")'],
--- a/Misc/ACKS +++ b/Misc/ACKS @@ -650,6 +650,7 @@ Piet van Oostrum Jason Orendorff Douglas Orr Michele OrrĂ¹ +Oleg Oshmyan Denis S. Otkidach Michael Otteneder R. M. Oudkerk
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -22,6 +22,10 @@ Core and Builtins Library ------- +- Issue #12085: Fix an attribute error in subprocess.Popen destructor if the