GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — gh-88886: Remove excessive encoding name normalization by serhiy-storchaka · Pull Request #137167 · python/cpython Conversation
|
|
This mainly restores the status quo prior to bpo-37751 and updates the documentation. But I am planning more changes. I was not sure about replacing spaces with hyphens? Should we kept this here, on leave it to the search function? Should we convert spaces to underscores instead? Or should we remove any transformation? I plan also to change |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The codecs lookup function now performs only minimal normalization of the encoding name before passing it to the search functions: all ASCII letters are converted to lower case, spaces are replaced with hyphens. Excessive normalization broke third-party codecs providers, like python-iconv. Revert "bpo-37751: Fix codecs.lookup() normalization (pythonGH-15092)" This reverts commit 20f59fe.
2df6169 to
ae1cae2
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo the one change to the news entry.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The docs still need updating: https://docs.python.org/3.15/library/codecs.html#encodings.normalize_encoding
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Is there anything left to be done for this PR ? After merging this one, I'd like to merge #136643 This will then give us a better story overall regarding encoding normalization in CPython: a central function which deals with normalization, avoiding duplicate normalizations as best as possible. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <[email protected]>
|
I do not think #136643 should be merged. Normalization is an internal affair of the search function. Different search functions can have different normalizations (including no normalization). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sure, but the encoding package uses the same normalization as the C implementation that's used internally (after all, the C implementation was crafted after the encoding package's normalization function), so it makes sense to reuse it that way. Of course, other codec packages can have their own search functions and normalizations. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The C code only needs support for few variants of few builting encodings (like "ISO-8859-1", "ISO_8859-1" and "iso8859-1"), but it does not need to support normalization for all encodings or more exotic forms of builting encodings (like "ISO_8859-1:1987" or "iso88591"). It is needed because some encodings should be accessible by their standard names before importing the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yes. I am well aware that it is internally only used for a few encodings, but since it is a C reimplementation of the encoding package's normalization function, it's a good idea to have this implemented in only one place. Given that the C version is faster, merging the PR is what I'd like to do. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…H-137167) The codecs lookup function now performs only minimal normalization of the encoding name before passing it to the search functions: all ASCII letters are converted to lower case, spaces are replaced with hyphens. Excessive normalization broke third-party codecs providers, like python-iconv. Revert "bpo-37751: Fix codecs.lookup() normalization (pythonGH-15092)" This reverts commit 20f59fe.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.