| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…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 overview2 files changed ± c-api/import.html ± whatsnew/changelog.html |
Sorry, something went wrong.
|
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, sys.modules shouldn't be involved; you're free to create any module object you wish. (Replacing existing sys.modules entries would be questionable of course, but, that's not in scope for PyImport_CreateModuleFromInitfunc.) 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. |
Sorry, something went wrong.
|
I agree with you, I think this PR can be closed, I'd fold the docs clarification into gh-157389 |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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