From 776e69b5b37a9f0678f2759c145ed26368aaba3f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 1 Jun 2011 01:03:00 +0200 Subject: 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. --- Lib/subprocess.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Lib/subprocess.py') diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 3734acde33..bdf85fc108 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -707,7 +707,10 @@ class Popen(object): def __del__(self, _maxint=sys.maxint, _active=_active): - if not self._child_created: + # 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): # We didn't get to successfully create a child process. return # In case the child hasn't been waited on, check if it's done. -- cgit v1.2.1