Eric Snow <ericsnowcurren...@gmail.com> added the comment:

On Wed, Oct 6, 2021 at 11:38 AM Guido van Rossum <rep...@bugs.python.org> wrote:
> I'm trying to understand the proposed solution, "have _imp.is_frozen() check 
> the module in sys.modules." Does that mean it would do a dict lookup first?

Correct.  We'd look up the module in sys.modules and, if there, check its 
loader.

> Maybe you should do that in the caller instead? importlib/_bootstrap.py calls 
> it a few times, but I'm not convinced that all call sites can be called with 
> "os.path" -- do you know which path was taken when this failed?

Good point.  The only place where it matters is the FrozenImporter methods that 
are wrapped with _requires_frozen().  So the fix can go there instead of 
_imp.is_frozen().

> I worry about the complexity of the importlib bootstrapping mechanism. 
> Grepping through the source for _bootstrap and _bootstrap_external has not 
> given me any understanding of how this works. Do you know if there are docs 
> for this? Or do we just need to ask Brett?

Are you talking about the use of _imp.is_frozen() or do you mean the code in 
_bootstrap.py (and _bootstrap_external.py) as a whole?  I don't believe there's 
any official documentation about the implementation in _bootstrap.py.  At best 
there have been some PyCon talks about how the import system works (but 
probably not at the level of the implementation) and Brett may have a blog post 
or two.  Keep in mind that I'm quite familiar with the importlib code, though 
Brett is definitely the mastermind behind the overall implementation.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45272>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to