diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 152b23c252c..af733deb323 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -923,7 +923,8 @@ def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9): try: import gzip - except ImportError: + gzip.GzipFile + except (ImportError, AttributeError): raise CompressionError, "gzip module is not available" pre, ext = os.path.splitext(name)