mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
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:
parent
887b3f2625
commit
2c318a1390
9 changed files with 117 additions and 502 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue