]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-152997: Support system locale encodings via an iconv-based codec (GH-153001)
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 9 Jul 2026 17:01:32 +0000 (20:01 +0300)
committerGitHub <noreply@github.com>
Thu, 9 Jul 2026 17:01:32 +0000 (20:01 +0300)
commit3ce7a1211c37f7f383dc67387ea7006273662820
treee0fdcd9bd591b2f426a1c598f01ce809f854fba1
parent33678dc79f00059aff09ac88f188ef2192031a85
gh-152997: Support system locale encodings via an iconv-based codec (GH-153001)

Where the C library provides iconv(), the codecs module now exposes every
encoding iconv() knows but Python has no built-in codec for -- the POSIX
counterpart of the Windows code-page support.  Use it by name (e.g.
"cp1133"), or with an "iconv:" prefix to force it over a built-in codec.

The codec is a last-resort search function and never shadows a built-in.
Both directions pivot through native-endian UTF-32, keeping one input unit
per code point so error handlers get the exact string position.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
18 files changed:
Doc/library/codecs.rst
Doc/whatsnew/3.16.rst
Include/internal/pycore_unicodeobject.h
Lib/encodings/__init__.py
Lib/encodings/_iconv_codecs.py [new file with mode: 0644]
Lib/test/test_codecs.py
Makefile.pre.in
Misc/NEWS.d/next/Library/2026-07-03-19-51-47.gh-issue-152997.i1ErzB.rst [new file with mode: 0644]
Modules/_codecsmodule.c
Modules/clinic/_codecsmodule.c.h
Objects/unicodeobject.c
PCbuild/_freeze_module.vcxproj
PCbuild/_freeze_module.vcxproj.filters
Python/frozen.c
Tools/build/freeze_modules.py
configure
configure.ac
pyconfig.h.in