diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-05-08 16:59:59 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2000-05-08 16:59:59 (GMT) |
commit | e298c3018cf5613aa3d8af4a5cc5652f1659f12b (patch) | |
tree | f0556d1430da984e3def128cb71f0a3435567db7 /Lib/gzip.py | |
parent | c554505ca1318fd7aed32086ceb4b53ae767ffa3 (diff) | |
download | cpython-e298c3018cf5613aa3d8af4a5cc5652f1659f12b.zip cpython-e298c3018cf5613aa3d8af4a5cc5652f1659f12b.tar.gz cpython-e298c3018cf5613aa3d8af4a5cc5652f1659f12b.tar.bz2 |
if the GzipFile constructor fails, the __del__ method is still
called. catch the resulting AttributeError and exit cleanly.
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 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() |