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 gvanrossum
Recipients barry, brett.cannon, eric.snow, gvanrossum, ncoghlan, ronaldoussoren
Date 2019-01-27.20:20:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAP7+vJL3L08ugjSSUJCZP0V77KZjQGosdf-LSNkTgmKpKns52g@mail.gmail.com>
In-reply-to <1548600621.45.0.645312277596.issue35806@roundup.psfhosted.org>
Content
Option 2 sounds best. I am also not against adding __spec__ but I think we
should support the idiom regardless, and I don’t consider this a bug in the
typing module — at best there’s a slight improvement.

On Sun, Jan 27, 2019 at 6:50 AM Nick Coghlan <report@bugs.python.org> wrote:

>
> Nick Coghlan <ncoghlan@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 <report@bugs.python.org>
> <https://bugs.python.org/issue35806>
> _______________________________________
>
-- 
--Guido (mobile)
History
Date User Action Args
2019-01-27 20:20:47gvanrossumsetrecipients: + gvanrossum, barry, brett.cannon, ronaldoussoren, ncoghlan, eric.snow
2019-01-27 20:20:46gvanrossumlinkissue35806 messages
2019-01-27 20:20:45gvanrossumcreate