Conversation
…tfunc() Modules created by PyImport_CreateModuleFromInitfunc() share the extensions cache and sys.modules with built-in modules. Passing a spec whose name is registered in PyImport_Inittab either silently ignored the init function (for an already loaded single-phase builtin, or for "sys" and "builtins") or replaced the built-in module in sys.modules (for a multi-phase builtin). Raise ImportError instead. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HoZE3WdRWQshvinfBZ137N
Documentation build overview
|
|
Looking at your post (and not checking the code in detail): at least for multi-phase modules, this looks like it's is working as expected. For multi-phase case, For single-phase, things are less clear, but I think the documented quirk applies: “For subsequent imports, Python does not call the initialization function again.” Bottom line, I thing scanning inittab is the users' responsibility. |
|
I agree with you, I think this PR can be closed, I'd fold the docs clarification into gh-157389 |
Modules created by PyImport_CreateModuleFromInitfunc() share the extensions cache and sys.modules with built-in modules. Passing a spec whose name is registered in PyImport_Inittab either silently ignored the init function (for an already loaded single-phase builtin, or for "sys" and "builtins") or replaced the built-in module in sys.modules (for a multi-phase builtin). Raise ImportError instead.
AI assisted with Claude Fable 5.1
PyImport_CreateModuleFromInitfunc(): wrong__name__for submodules, non-ASCII names rejected, inittab name clashes #157384