From: Jeremy Hylton Date: Mon, 8 May 2000 16:59:59 +0000 (+0000) Subject: if the GzipFile constructor fails, the __del__ method is still X-Git-Tag: v2.0b1~1812 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e298c3018cf5613aa3d8af4a5cc5652f1659f12b;p=thirdparty%2FPython%2Fcpython.git if the GzipFile constructor fails, the __del__ method is still called. catch the resulting AttributeError and exit cleanly. --- diff --git a/Lib/gzip.py b/Lib/gzip.py index 25278bef3b7c..43501d40a7a8 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -253,9 +253,13 @@ class GzipFile: self.myfileobj = None def __del__(self): - if (self.myfileobj is not None or - self.fileobj is not None): - self.close() + try: + if (self.myfileobj is None and + self.fileobj is None): + return + except AttributeError: + return + self.close() def flush(self): self.fileobj.flush()