[issue2377] Replace __import__ w/ importlib.__import__

Antoine Pitrou report at bugs.python.org
Sat Mar 10 00:11:26 CET 2012


Antoine Pitrou <pitrou at free.fr> added the comment:

> One is ``python -v`` support. sys.flags has a verbose attribute that
> can be used to properly guard printing imported modules. It might be
> tricky, though, if sys.stderr is not set up properly during very early
> imports.

Might or might not. You should try, there's a fallback stderr at
interpreter startup.

> Two is getting __import__() for situations where another import is
> triggered (e.g. fromlist stuff). I think the proper semantics is
> ``globals['__builtins__']['__import__'] if '__builtins__' in globals
> else  builtins.__import__``. Now where this gets tricky is that doing
> this means importlib.__import__(), when used directly from the
> importlib module, would sometimes use its implementation, and in other
> cases use builtins.__import__(). So either importlib.__import__() gets
> forked from builtins.__import__() so that it always uses importlib
> internally or simply don't worry about it and just have
> importlib.__import__() use builtins.__import__() when the need to
> trigger another import comes up. What do people think should happen?

I don't think I have understood anything :) It probably doesn't help,
but I think the __import__ signature is generally crazy, though.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2377>
_______________________________________


More information about the Python-bugs-list mailing list