[issue14285] Traceback wrong on ImportError while executing a package
Nick Coghlan
report at bugs.python.org
Fri Dec 4 01:38:33 EST 2015
Nick Coghlan added the comment:
I'm wondering if there might be a simpler option: use rpartition() to strip off any trailing segment (whether that's "__main__" or not), and then always do a plain dynamic import of that package (if any). Something like the following at the start of _get_module_details():
pkg_name, is_submodule, submodule = mod_name.rpartition(".")
if is_submodule:
__import__(pkg_name)
The key is that we *don't* want to be relying on the fact find_spec() will import parent packages implicitly.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14285>
_______________________________________
More information about the Python-bugs-list
mailing list