We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 97db96c commit 6b63689Copy full SHA for 6b63689
Lib/zipfile/__init__.py
@@ -14,8 +14,12 @@
14
import threading
15
import time
16
17
-import zlib
18
-crc32 = zlib.crc32
+try:
+ import zlib
19
+ crc32 = zlib.crc32
20
+except ImportError:
21
+ zlib = None
22
+ crc32 = binascii.crc32
23
24
try:
25
import bz2 # We may need its compression method
@@ -767,8 +771,12 @@ def decompress(self, data):
767
771
}
768
772
769
773
def _check_compression(compression):
770
- if compression in (ZIP_STORED, ZIP_DEFLATED):
774
+ if compression == ZIP_STORED:
775
pass
776
+ elif compression == ZIP_DEFLATED:
777
+ if not zlib:
778
+ raise RuntimeError(
779
+ "Compression requires the (missing) zlib module")
780
elif compression == ZIP_BZIP2:
781
if not bz2:
782
raise RuntimeError(
0 commit comments