This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: zipfile: read after write fails for non-ascii files
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-06-21 20:08 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 21040 merged serhiy.storchaka, 2020-06-22 07:27
PR 21048 merged miss-islington, 2020-06-22 08:24
PR 21049 closed miss-islington, 2020-06-22 08:24
PR 21050 merged miss-islington, 2020-06-22 08:26
Messages (4)
msg372018 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-06-21 20:08
When open a ZIP archive, write a file with non-ascii name in it, and, not closing the archive, read that file back, it fails:

>>> import zipfile
>>> with zipfile.ZipFile('', 'w') as zf:
...     zf.writestr('йцукен', '')
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/usr/lib/python3.8/", line 1440, in read
    with, "r", pwd) as fp:
  File "/usr/lib/python3.8/", line 1521, in open
    raise BadZipFile(
zipfile.BadZipFile: File name in directory 'йцукен' and header b'\xd0\xb9\xd1\x86\xd1\x83\xd0\xba\xd0\xb5\xd0\xbd' differ.
msg372047 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-06-22 08:24
New changeset 36ff513f82e372ed3cea0bf7cbdf15a1ef6dab9e by Serhiy Storchaka in branch 'master':
bpo-41068: Fix read after write in zipfile for non-ASCII files names. (GH-21040)
msg372051 - (view) Author: miss-islington (miss-islington) Date: 2020-06-22 08:40
New changeset d7f37d1ed4fd38555e3e5aad32d515c96b528df5 by Miss Islington (bot) in branch '3.8':
bpo-41068: Fix read after write in zipfile for non-ASCII files names. (GH-21040)
msg372053 - (view) Author: miss-islington (miss-islington) Date: 2020-06-22 08:46
New changeset c916c48afc02c26a50843c7b381a2b567bb72e46 by Miss Islington (bot) in branch '3.9':
bpo-41068: Fix read after write in zipfile for non-ASCII files names. (GH-21040)
Date User Action Args
2022-04-11 14:59:32adminsetgithub: 85240
2020-06-28 13:01:56ned.deilysetversions: - Python 3.7
2020-06-22 09:34:31serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-06-22 08:46:15miss-islingtonsetmessages: + msg372053
2020-06-22 08:40:18miss-islingtonsetmessages: + msg372051
2020-06-22 08:26:37miss-islingtonsetpull_requests: + pull_request20221
2020-06-22 08:24:37miss-islingtonsetpull_requests: + pull_request20220
2020-06-22 08:24:30miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request20219
2020-06-22 08:24:20serhiy.storchakasetmessages: + msg372047
2020-06-22 07:29:16serhiy.storchakalinkissue41069 dependencies
2020-06-22 07:27:42serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request20211
2020-06-21 20:40:53serhiy.storchakasetassignee: serhiy.storchaka
2020-06-21 20:08:04serhiy.storchakacreate