[New-bugs-announce] [issue29787] Internal importlib frames visible when module imported by import_module throws exception

Ulrich Petri report at bugs.python.org
Fri Mar 10 10:50:57 EST 2017


New submission from Ulrich Petri:

Importing a module that raises an exception on import trough `importlib.import_module()` causes importlib to not strip it's internal frames from the traceback.


Minimal example:

--a.py--
import importlib

importlib.import_module("b")
--a.py--


--b.py--
raise Exception()
--b.py--

#~ python3.6 a.py
Traceback (most recent call last):
  File "a.py", line 3, in <module>
    importlib.import_module("b")
  File "/Users/ulo/.pythonz/pythons/CPython-3.6.0/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/Users/ulo/t/b.py", line 1, in <module>
    raise Exception()
Exception

----------
messages: 289381
nosy: ulope
priority: normal
severity: normal
status: open
title: Internal importlib frames visible when module imported by import_module throws exception
type: behavior
versions: Python 3.6

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


More information about the New-bugs-announce mailing list