Skip to content

gh-157384: Accept non-ASCII names in PyImport_CreateModuleFromInitfunc() - #157390

Open
itamaro wants to merge 1 commit into
python:mainfrom
itamaro:gh-116146-initfunc-nonascii
Open

gh-157384: Accept non-ASCII names in PyImport_CreateModuleFromInitfunc()#157390
itamaro wants to merge 1 commit into
python:mainfrom
itamaro:gh-116146-initfunc-nonascii

Conversation

@itamaro

@itamaro itamaro commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

The builtin loader info encoded the module name as ASCII, so a non-ASCII spec name failed with UnicodeEncodeError even for multi-phase init modules, which support such names when loaded dynamically. Fall back to UTF-8 and mark the name as non-ASCII, so that multi-phase init works and single-phase init is rejected with the same error as for dynamically loaded extensions.

AI assisted with Claude Fable 5.1

…nitfunc()

The builtin loader info encoded the module name as ASCII, so a
non-ASCII spec name failed with UnicodeEncodeError even for multi-phase
init modules, which support such names when loaded dynamically.  Fall
back to UTF-8 and mark the name as non-ASCII, so that multi-phase init
works and single-phase init is rejected with the same error as for
dynamically loaded extensions.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HoZE3WdRWQshvinfBZ137N
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.15 pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant