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 ncoghlan
Recipients barry, brett.cannon, eric.snow, gvanrossum, ncoghlan, ronaldoussoren
Date 2019-01-27.14:50:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1548600621.45.0.645312277596.issue35806@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-01-27 14:50:23ncoghlansetrecipients: + ncoghlan, gvanrossum, barry, brett.cannon, ronaldoussoren, eric.snow
2019-01-27 14:50:21ncoghlansetmessageid: <1548600621.45.0.645312277596.issue35806@roundup.psfhosted.org>
2019-01-27 14:50:21ncoghlanlinkissue35806 messages
2019-01-27 14:50:21ncoghlancreate