Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ec6824

Browse files
committed
Fix test_tarfile failure when gzip is not available
The module would exist, but be empty if already imported. This change ensures we have gzip available.
1 parent ffe33b7 commit 4ec6824

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/tarfile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,8 @@ def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9):
923923

924924
try:
925925
import gzip
926-
except ImportError:
926+
gzip.GzipFile
927+
except (ImportError, AttributeError):
927928
raise CompressionError, "gzip module is not available"
928929

929930
pre, ext = os.path.splitext(name)

0 commit comments

Comments
 (0)