Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Lib/test/test_zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,11 @@ def test_write_unicode_filenames(self):
self.assertEqual(zf.filelist[0].filename, "foo.txt")
self.assertEqual(zf.filelist[1].filename, "\xf6.txt")

def test_read_after_write_unicode_filenames(self):
with zipfile.ZipFile(TESTFN2, 'w') as zipfp:
zipfp.writestr('приклад', b'sample')
self.assertEqual(zipfp.read('приклад'), b'sample')

def test_exclusive_create_zip_file(self):
"""Test exclusive creating a new zipfile."""
unlink(TESTFN2)
Expand Down
2 changes: 1 addition & 1 deletion Lib/zipfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ def open(self, name, mode="r", pwd=None, *, force_zip64=False):
# strong encryption
raise NotImplementedError("strong encryption (flag bit 6)")

if zinfo.flag_bits & 0x800:
if fheader[_FH_GENERAL_PURPOSE_FLAG_BITS] & 0x800:
# UTF-8 filename
fname_str = fname.decode("utf-8")
else:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed reading files with non-ASCII names from ZIP archive directly after
writing them.