classification
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
process
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 2020-06-28 13:01 by ned.deily. 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('test.zip', 'w') as zf:
...     zf.writestr('йцукен', '')
...     zf.read('йцукен')
... 
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/usr/lib/python3.8/zipfile.py", line 1440, in read
    with self.open(name, "r", pwd) as fp:
  File "/usr/lib/python3.8/zipfile.py", 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)
https://github.com/python/cpython/commit/36ff513f82e372ed3cea0bf7cbdf15a1ef6dab9e
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)
https://github.com/python/cpython/commit/d7f37d1ed4fd38555e3e5aad32d515c96b528df5
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)
https://github.com/python/cpython/commit/c916c48afc02c26a50843c7b381a2b567bb72e46
History
Date User Action Args
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