diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2012-07-29 10:30:36 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2012-07-29 10:30:36 (GMT) |
commit | 5ee9892406c4299826f553b6b73c046229c6040c (patch) | |
tree | ae358fd32ceea1f0debd2fad2a94e7100e734d7c /Lib/importlib/_bootstrap.py | |
parent | bb9b1c165d0193e6783981c1ac1e0ab9bf171c4c (diff) | |
download | cpython-5ee9892406c4299826f553b6b73c046229c6040c.zip cpython-5ee9892406c4299826f553b6b73c046229c6040c.tar.gz cpython-5ee9892406c4299826f553b6b73c046229c6040c.tar.bz2 |
Close #15425: Eliminate more importlib related traceback noise
Diffstat (limited to 'Lib/importlib/_bootstrap.py')
-rw-r--r-- | Lib/importlib/_bootstrap.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py index a447565..6a869f7 100644 --- a/Lib/importlib/_bootstrap.py +++ b/Lib/importlib/_bootstrap.py @@ -1472,7 +1472,7 @@ def _find_and_load_unlocked(name, import_): parent = name.rpartition('.')[0] if parent: if parent not in sys.modules: - import_(parent) + _recursive_import(import_, parent) # Crazy side-effects! if name in sys.modules: return sys.modules[name] @@ -1550,6 +1550,12 @@ def _gcd_import(name, package=None, level=0): _lock_unlock_module(name) return module +def _recursive_import(import_, name): + """Common exit point for recursive calls to the import machinery + + This simplifies the process of stripping importlib from tracebacks + """ + return import_(name) def _handle_fromlist(module, fromlist, import_): """Figure out what __import__ should return. @@ -1569,7 +1575,8 @@ def _handle_fromlist(module, fromlist, import_): fromlist.extend(module.__all__) for x in fromlist: if not hasattr(module, x): - import_('{}.{}'.format(module.__name__, x)) + _recursive_import(import_, + '{}.{}'.format(module.__name__, x)) return module |