summaryrefslogtreecommitdiff
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-06-01 00:58:57 +0200
committerVictor Stinner <victor.stinner@haypocalc.com>2011-06-01 00:58:57 +0200
commit1b5b9d7434ad3c082ec96688e8d0e7edf6b8c432 (patch)
treefbf7948bdc6d76c38441b23fc6ff3e7faf32df43 /Lib/test/test_subprocess.py
parent0bb299165344129dcdc0891233f3799ca258d4a3 (diff)
parent87b9bc3893bac402bd773a83ee6734507f978607 (diff)
downloadcpython-git-1b5b9d7434ad3c082ec96688e8d0e7edf6b8c432.tar.gz
(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.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 686c1b14c9..859df34bfd 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -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")'],