Skip to content

Commit 51a2221

Browse files
committed
Remove unneeded zlib dependency
- Use `zipfile.crc32` rather than `zlib.crc32` since it can work without `zlib`.
1 parent 7b1010a commit 51a2221

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Lib/test/test_zipfile/test_core.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,8 +1894,7 @@ def create_zipfile_with_extra_data(self, filename, extra_data_name):
18941894
tag_for_unicode_path = b'\x75\x70'
18951895
version_of_unicode_path = b'\x01'
18961896

1897-
import zlib
1898-
filename_crc = struct.pack('<L', zlib.crc32(filename_encoded))
1897+
filename_crc = struct.pack('<L', zipfile.crc32(filename_encoded))
18991898

19001899
extra_data = version_of_unicode_path + filename_crc + extra_data_name
19011900
tsize = len(extra_data).to_bytes(2, 'little')
@@ -1905,19 +1904,16 @@ def create_zipfile_with_extra_data(self, filename, extra_data_name):
19051904
# add the file to the ZIP archive
19061905
zf.writestr(zip_info, b'Hello World!')
19071906

1908-
@requires_zlib()
19091907
def test_read_zipfile_containing_unicode_path_extra_field(self):
19101908
self.create_zipfile_with_extra_data("이름.txt", "이름.txt".encode("utf-8"))
19111909
with zipfile.ZipFile(TESTFN, "r") as zf:
19121910
self.assertEqual(zf.filelist[0].filename, "이름.txt")
19131911

1914-
@requires_zlib()
19151912
def test_read_zipfile_warning(self):
19161913
self.create_zipfile_with_extra_data("이름.txt", b"")
19171914
with self.assertWarns(UserWarning):
19181915
zipfile.ZipFile(TESTFN, "r").close()
19191916

1920-
@requires_zlib()
19211917
def test_read_zipfile_error(self):
19221918
self.create_zipfile_with_extra_data("이름.txt", b"\xff")
19231919
with self.assertRaises(zipfile.BadZipfile):

0 commit comments

Comments
 (0)