You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
zipimport.zipimporter raises UnicodeDecodeError instead of ZipImportError for an invalid UTF-8 file name #153679
zipimport.zipimporter() is documented to raise zipimport.ZipImportError
for an invalid archive, but it leaks a raw UnicodeDecodeError when a central
directory entry sets the UTF-8 file name flag (0x800) yet stores bytes that
are not valid UTF-8.
In _read_directory() (Lib/zipimport.py) the UTF-8 branch does name = name.decode() with no error handling, whereas the sibling non-UTF-8
branch already guards UnicodeDecodeError and falls back to latin-1/cp437.
Every other corruption path in the function raises ZipImportError.
Activity
pythongh-153679: Trim the test comment and NEWS wording
gh-153679: Raise `ZipImportError` for an invalid UTF-8 file name in `…
StanFromIreland commentedon Oct 24, 2026
Thanks for the repirt and fix!
[3.14] gh-153679: Raise `ZipImportError` for an invalid UTF-8 file na…
[3.15] gh-153679: Raise `ZipImportError` for an invalid UTF-8 file na…