[issue12085] subprocess.Popen.__del__ raises AttributeError if __init__ was called with an invalid argument list

Guido van Rossum report at bugs.python.org
Sun Sep 22 00:44:25 CEST 2013


Guido van Rossum added the comment:

FWIW, using class attributes to ensure __del__ does not hit AttributeError when __init__ failed is more idiomatic than using three-argument getattr().

The reason: in general it is possible that __del__ calls almost any other method on a class (e.g. for a buffered I.O stream open for writing, __del__ might call close() which might attempt to flush the buffer).  It is not reasonable (and ugly :-) to use three-argument in all code that might be called by __del__.  But it is reasonable to use class attributes to pre-initialize instance variables set by __init__ to "safe" defaults like None.

----------
nosy: +gvanrossum

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12085>
_______________________________________


More information about the Python-bugs-list mailing list