Skip to content

gh-155006: Encode an error handler's replacement strictly - #155008

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-155006-iconv-recursion
Aug 2, 2026
Merged

gh-155006: Encode an error handler's replacement strictly#155008
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-155006-iconv-recursion

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

A str replacement was re-encoded with the same error handler, so a replacement that is itself unencodable called the handler again, without end. It is encoded strictly now, and one that does not fit is reported against the input character.

replace therefore raises where it used to recurse, which includes the charsets with no '?' at all, 38 of the names here: E13B, Braille, the INIS subsets and others. ignore is unaffected.

Encoding a😀b with the four handlers recursed for 274 encodings and for none now. The test fails without the change.

The iconv codecs are new in 3.16, so there is no NEWS entry.

Encoding it with the same error handler could never terminate: a replacement
that is itself unencodable calls the handler again. A replacement that does
not fit is now reported against the input character.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@serhiy-storchaka
serhiy-storchaka merged commit 685ad02 into python:main Aug 2, 2026
54 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the gh-155006-iconv-recursion branch August 2, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant