Skip to content

Commit c69cf30

Browse files
committed
Fix encoding error
1 parent f04ef07 commit c69cf30

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Lib/test/test_zipfile/test_core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,8 @@ def test_generated_valid_zip64_extra(self):
11911191

11921192
def test_generated_extra_in_local_entry(self):
11931193
"""Should not write duplicated or improper fields to local file entry."""
1194+
comment = '\u4e00'.encode('utf-8')
1195+
11941196
# zip64
11951197
fh = io.BytesIO()
11961198
with zipfile.ZipFile(fh, 'w') as zh:
@@ -1200,7 +1202,7 @@ def test_generated_extra_in_local_entry(self):
12001202
struct.pack('<HHQQ', 0x0001, 16, 0, 0) +
12011203
# unicode comment
12021204
struct.pack('<HHBL5s', 0x6375, 10, 1,
1203-
zipfile.crc32(b'\u4e00'), b'\u4e00') +
1205+
zipfile.crc32(comment), comment) +
12041206
# invalid tail
12051207
b'zzz'
12061208
)
@@ -1224,7 +1226,7 @@ def test_generated_extra_in_local_entry(self):
12241226
struct.pack('<HHQQ', 0x0001, 16, 0, 0) +
12251227
# unicode comment
12261228
struct.pack('<HHBL5s', 0x6375, 10, 1,
1227-
zipfile.crc32(b'\u4e00'), b'\u4e00') +
1229+
zipfile.crc32(comment), comment) +
12281230
# invalid tail
12291231
b'zzz'
12301232
)

0 commit comments

Comments
 (0)