From e298c3018cf5613aa3d8af4a5cc5652f1659f12b Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Mon, 8 May 2000 16:59:59 +0000 Subject: if the GzipFile constructor fails, the __del__ method is still called. catch the resulting AttributeError and exit cleanly. --- Lib/gzip.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/gzip.py b/Lib/gzip.py index 25278be..43501d4 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() -- cgit v0.12