Skip to content

Leave out the utf_7_imap codec added in Python 3.16 - #825

Merged
Ousret merged 1 commit into
jawah:masterfrom
Rahul-cs50:fix/824-future-bug-test-failures-with-python-3-1
Oct 20, 2026
Merged

Ousret merged 1 commit into
jawah:masterfrom
Rahul-cs50:fix/824-future-bug-test-failures-with-python-3-1

Conversation

@Rahul-cs50

Copy link
Copy Markdown
Contributor

Fixes #824

Python 3.16 adds the utf_7_imap codec (python/cpython@562606d), the modified UTF-7 of IMAP mailbox names. It shows up in encodings.aliases, so it lands in IANA_SUPPORTED. Its decoder raises UnicodeError: Unsupported error handling: ignore for any handler other than "strict", and detection builds decoders with errors="ignore" (encoding_unicode_range(), cp_similarity()). On 3.16 that broke detection for samples such as cp1252, cp1253 and mac_cyrillic.

It isn't an encoding for documents, so this leaves it out of IANA_SUPPORTED, like rot_13, tactis and mbcs. The new test checks that every supported encoding accepts errors="ignore", so the next codec like this fails a test instead of detection.

Tested on Python 3.16.0a1 (python:3.16.0a1-slim):

  • before: 11 failed, 514 passed (the failures from the issue)
  • after: 626 passed
  • the new test without the fix fails only for utf_7_imap

On Python ≤ 3.15 the codec doesn't exist, so nothing changes there.

Python 3.16 adds the utf_7_imap codec (the modified UTF-7 of IMAP
mailbox names). Its decoder raises UnicodeError for any error handler
other than "strict", and detection decodes candidates with
errors="ignore", so detecting a single-byte encoding could fail. Leave
it out of IANA_SUPPORTED, like rot_13, tactis and mbcs.

Fixes jawah#824
@Rahul-cs50
Rahul-cs50 requested a review from Ousret as a code owner October 20, 2026 14:48

@Ousret Ousret left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Ousret
Ousret merged commit 0a92017 into jawah:master Oct 20, 2026
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[FUTURE BUG] Test failures with Python 3.16.0a1

2 participants