-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
Inittab modules in packages hit an assertion since Python 3.13 #140011
Copy link
Copy link
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Fields
Give feedbackNo fields configured for issues without a type.
Bug report
Bug description:
Adding static modules using inittab can include modules in packages (aka dotted-modules), like this:
and be imported like so in Python code:
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):
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
Linked PRs