Rewrite the code implementing __import__ for importlib. Now it is much simpler

and relies much more on meta path finders to abstract out various parts of
import.

As part of this the semantics for import_module tightened up and now follow
__import__ much more closely (biggest thing is that the 'package' argument must
now already be imported, else a SystemError is raised).
This commit is contained in:
Brett Cannon 2009-02-07 01:15:27 +00:00
parent 887b3f2625
commit 2c318a1390
9 changed files with 117 additions and 502 deletions

View file

@ -1,5 +1,5 @@
import functools
import importlib
import importlib._bootstrap
using___import__ = False
@ -9,7 +9,8 @@ def import_(*args, **kwargs):
"""Delegate to allow for injecting different implementations of import."""
if using___import__:
return __import__(*args, **kwargs)
return importlib.Import()(*args, **kwargs)
#return importlib.Import()(*args, **kwargs)
return importlib._bootstrap._import(*args, **kwargs)
def importlib_only(fxn):