-
-
Couldn't load subscription status.
- Fork 33.3k
Description
Bug report
Bug description:
Adding static modules using inittab can include modules in packages (aka dotted-modules), like this:
PyImport_AppendInittab("inittab.staticmod", PyInit_staticmod);and be imported like so in Python code:
import inittab.staticmod
inittab.staticmod.say_hello()This works fine when using a CPython build with assertions disabled, and also works fine with Python 3.12 with assertions enabled.
Since Python 3.13 (and still true on main), importing a dotted-inittab-module in an assertions-enabled build hits a new assertion (added in gh-118204):
Assertion failed: (PyUnicode_FindChar(name, '.', 0, PyUnicode_GetLength(name), -1) == -1), function _Py_ext_module_loader_info_init_for_builtin, file importdl.c, line 178.
It is unclear to me whether it was intentional to make dotted-inittab-modules "not supported", or it was unintended consequence.
The docs don't mention such a limitation when using inittab, and at least as of gh-102700, explicit support for this scenario was added in Python 3.12 and backported to 3.11.
I created a demo repo to demonstrate the issue, with several PRs against it demonstrating that it works with assertions disabled and in 3.12 with assertions enabled.
CPython versions tested on:
3.15, 3.14, CPython main branch, 3.13
Operating systems tested on:
macOS