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
gettext.GNUTranslations raises struct.error instead of OSError on a malformed .mo file #153605
gettext.GNUTranslations parses a .mo file by unpacking its header and seek
tables with struct.unpack, but never checks the file is long enough. A
truncated file (shorter than the 20-byte header) or one whose seek tables point
past the end raises a raw struct.error instead of the OSError the module
already raises for other malformed input (a bad magic number, a bad version, or
an out-of-range string offset). The documentation states OSError is raised for
problems while reading the file, so the struct.error is an undocumented leak.
Since OSError is not specific to gettext, other option -- simply document other exceptions.
That's also an option, but I think the error message may currently be confusing for users (it looks like a bug in gettext rather than your catalogue!), so I merged a simplified patch.
Activity
serhiy-storchaka commentedon Aug 17, 2026
Since
OSErroris not specific togettext, other option -- simply document other exceptions.gh-153605: Fix `gettext.GNUTranslations` raising `struct.error` on a …
StanFromIreland commentedon Oct 25, 2026
That's also an option, but I think the error message may currently be confusing for users (it looks like a bug in
gettextrather than your catalogue!), so I merged a simplified patch.