Nick Coghlan <ncogh...@gmail.com> added the comment:
Closing this without any changes contradicts the answer we gave Ronald on #35791 that it's expected behaviour for importlib.find_spec() to throw an exception for already loaded modules without a __spec__ attribute. So if this stays closed, then we should reopen #35791, and treat it as a feature request to either: 1. add a "ignore_module_cache" option to bypass sys.modules; or 2. revert to searching for the original spec in cases where the sys.modules entry has no __spec__ attribute (which has the virtue of just working for cases of the "replace yourself in sys.modules" idiom) That said, the typing pseudo submodules *can* populate their __spec__ with useful information by copying most of their attributes from `typing.__spec__`, but setting their __spec__.loader attribute to one that throws an ImportError with a message saying to import `typing` instead of attempting to reload the submodule directly. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35806> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com