@@ -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