Repository navigation
[3.15] gh-155247: Use raw string content for the extensions cache key (GH-155249) - #162686
Merged
serhiy-storchaka merged 1 commit intoNov 26, 2026
Merged
Conversation
…he key (pythonGH-155249) The key of the extensions cache was built with _PyUnicode_AsUTF8NoNUL(), so importing an extension module failed with UnicodeEncodeError if its path contained characters unencodable in UTF-8, e.g. surrogate escapes of an undecodable file name. The raw content of the strings is now used. The rejection of embedded null characters, which was a side effect of the UTF-8 encoding, is now explicit in the extension module loader. (cherry picked from commit 6a18ae4) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
serhiy-storchaka
requested review from
FFY00,
brettcannon,
ericsnowcurrently,
kumaraditya303,
ncoghlan and
warsaw
as code owners
November 26, 2026 13:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(cherry picked from commit 6a18ae4)
Manual backport: the cherry-pick conflicted because in 3.15
_Py_ext_module_loader_info_init()takes the filename as an argument and cleans up with_Py_ext_module_loader_info_clear()instead ofgoto error. The embedded null character check is therefore applied tofilenamebefore it is stored, in that style. Teststest_create_dynamic_no_originandtest_create_builtinfrom the conflicting context only exist on main and are not added. Everything else is identical to the original commit.🤖 Generated with Claude Code