diff options
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r-- | Lib/gzip.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py index 25278bef3b..43501d40a7 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() |