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

Terry J. Reedy report at bugs.python.org
Sun Sep 15 07:30:39 CEST 2013


Terry J. Reedy added the comment:

I think this patch is a false solution and should be reverted. Oleg should have been told to use sys.version to make the correct call. Given how Python is, that is the correct solution to his problem.

The result of this patch is #19021: an AttributeError on shutdown when getattr gets cleared before the Popen instance.

The problem of Python putting out an uncatchable error message when deleting an uninitialized instance is generic and not specific to Popen.

class C():
    def __init__(self): self.a = 1
    def __del__(self): self.a

try:
    C(1)
except (TypeError, AttributeError): pass

# prints
Exception AttributeError: "'C' object has no attribute 'a'" in <bound method C.__del__ of <__main__.C object at 0x00000000033FB128>> ignored

If there is to be any change, it should be as generic as the problem. Perhaps that message should simply be eliminated. Perhaps it should be a Warning, which could be blocked. Perhaps there should be a real AttributeError chained with the TypeError.


What we should not do and should not tell people to do is add at least one getattr call to every __del__ method.

----------
nosy: +terry.reedy

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


More information about the Python-bugs-list mailing list