Skip to content

[3.14] gh-155247: Use raw string content for the extensions cache key (GH-155249) - #162687

Merged
serhiy-storchaka merged 1 commit into
python:3.14from
serhiy-storchaka:backport-6a18ae4-3.14
Nov 26, 2026
Merged

serhiy-storchaka merged 1 commit into
python:3.14from
serhiy-storchaka:backport-6a18ae4-3.14

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

(cherry picked from commit 6a18ae4)

Manual backport: the cherry-pick conflicted because in 3.14 _Py_ext_module_loader_info_init() takes the filename as an argument and cleans up with _Py_ext_module_loader_info_clear() instead of goto error. The embedded null character check is therefore applied to filename before it is stored, in that style. Tests test_create_dynamic_no_origin, test_create_builtin and test_filter_syntax_warnings_by_module from the conflicting context only exist on main and are not added. Everything else is identical to the original commit.

🤖 Generated with Claude Code

…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>
@bedevere-app bedevere-app Bot added the type-bug An unexpected behavior, bug, or error label Nov 26, 2026
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) November 26, 2026 14:20
@serhiy-storchaka
serhiy-storchaka merged commit 6d558e1 into python:3.14 Nov 26, 2026
91 of 93 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant