mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
(Merge 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.
This commit is contained in:
commit
1b5b9d7434
4 changed files with 19 additions and 1 deletions
|
@ -146,6 +146,16 @@ class ProcessTestCase(BaseTestCase):
|
|||
env=newenv)
|
||||
self.assertEqual(rc, 1)
|
||||
|
||||
def test_invalid_args(self):
|
||||
# Popen() called with invalid arguments should raise TypeError
|
||||
# but Popen.__del__ should not complain (issue #12085)
|
||||
with support.captured_stderr() as s:
|
||||
self.assertRaises(TypeError, subprocess.Popen, invalid_arg_name=1)
|
||||
argcount = subprocess.Popen.__init__.__code__.co_argcount
|
||||
too_many_args = [0] * (argcount + 1)
|
||||
self.assertRaises(TypeError, subprocess.Popen, *too_many_args)
|
||||
self.assertEqual(s.getvalue(), '')
|
||||
|
||||
def test_stdin_none(self):
|
||||
# .stdin is None when not redirected
|
||||
p = subprocess.Popen([sys.executable, "-c", 'print("banana")'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue