| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Build math as an extension package (math/__init__ and math/integer) so that math.integer is a genuine extension submodule instead of the _math_integer extension module patched at runtime to look like one. This drops the sys.modules['_math_integer'] leak and gives math.integer's functions a correct __module__. Modules/makesetup now accepts dotted module names, mapping each to its registration name, on-disk path and init symbol; a package initializer is written with an explicit __init__ leaf (math.__init__). Makefile.pre.in keeps sub-directories when staging and installing shared modules, and check_extension_modules.py and generate_stdlib_module_names.py handle package and dotted submodule names. The package works both for shared builds and for builds where math is a builtin (Windows, WebAssembly): math's exec slot sets __path__ when the import machinery does not, and the static inittab uses a symbol derived from the full dotted name (PyInit_math_integer) to stay unique, selected with Py_BUILD_CORE_BUILTIN. ExtensionFileLoader.is_package() now mirrors FileLoader by returning False for the "__init__" name itself, so that modulefinder (used by Tools/freeze) does not recurse on an extension package. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@hugovk , it would be nice to land this in 3.15, where math.integer was introduced, so we will no longer use hacks. |
Sorry, something went wrong.
|
I think this should have testing during an alpha phase, so let's not backport to 3.15. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Build math as a real extension package (math/__init__ and math/integer), so that math.integer is a genuine extension submodule instead of the _math_integer extension module patched at runtime to look like a submodule.
This removes the leftover sys.modules['_math_integer'], gives math.integer's functions a correct __module__, and drops the __name__/__module__ and _PyImport_SetModuleString workarounds.
How
Shared vs. builtin
Works both for the usual shared build and for builds where math is compiled into the interpreter as a builtin (Windows, WebAssembly):
Testing
🤖 Generated with Claude Code
https://claude.ai/code/session_01R4YFmYjuT6XeiobFzeQjDp