This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author petr.viktorin
Recipients brett.cannon, petr.viktorin
Date 2020-09-16.13:23:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1600262618.31.0.325694341017.issue41797@roundup.psfhosted.org>
In-reply-to
Content
One underlying issue from bpo-41631 is that importlib.util.LazyLoader produces modules that are only fully loaded after an attribute is accessed (through __getattribute__).

C-API functions like PyModule_GetState, PyModule_GetDict and such do not get attributes, and when called on a _LazyModule, they might try to access uninitialized C-level state.

I see two possible ways to fix this:
- Make PyModule_GetState, etc. trigger a full load. Since this is C-API, it would need a fast (no Python code) way either to do the full load or to detect _LazyModule.
- Make LazyLoader eager for either all extension & builtin modules, or for modules that have C-level storage. The latter would need a way to pass info from PyModuleDef to the loader.


Brett, does that analysis make sense from the importlib POV?
History
Date User Action Args
2020-09-16 13:23:38petr.viktorinsetrecipients: + petr.viktorin, brett.cannon
2020-09-16 13:23:38petr.viktorinsetmessageid: <1600262618.31.0.325694341017.issue41797@roundup.psfhosted.org>
2020-09-16 13:23:38petr.viktorinlinkissue41797 messages
2020-09-16 13:23:38petr.viktorincreate