[Python-Dev] Silencing IO errors on del/dealloc? (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Sun Feb 22 20:32:32 CET 2009
- Previous message: [Python-Dev] Silencing IO errors on del/dealloc?
- Next message: [Python-Dev] Silencing IO errors on del/dealloc?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Guido van Rossum <guido python.org> writes:
OTOH the is a much larger category of false positives, where a close() call raise an exception for some spurious reason (see the quoted comment) but no harm is done; in the past the tracebacks printed for del by default have caused nothing but confuse users (who think something is seriously wrong but have no way to debug it). The svn history of those lines may have more pointers.
Well this code dates back to the first checkin in the py3k branch. Apparently the old p3yk branch is not there anymore...
I understand the missing globals on shutdown problem, but the error may also be a legitimate programming error, where a close() implementation fails for whatever reason. At least displaying the error may encourage the programmer to strengthen his implementation.
How about the following compromise:
try:
closed = self.closed
except:
# Object is in an unusable state, don't attempt anything
pass
else:
if not closed:
self.close()
Regards
Antoine.
- Previous message: [Python-Dev] Silencing IO errors on del/dealloc?
- Next message: [Python-Dev] Silencing IO errors on del/dealloc?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]