[issue19771] runpy should check ImportError.name before wrapping it

Martin Panter report at bugs.python.org
Wed Mar 11 09:13:02 CET 2015


Martin Panter added the comment:

Posting a new patch with the following changes:

* Added Poleto’s original tests, updated according to review comments. Combined the flag and source code string parameters.

* Used a different approach to guessing where the offending ImportError came from. Now it checks if the module got added to sys.modules, which seems to work in all cases I tried. It no longer does what the bug title says (check ImportError.name), but I think it is a better workaround or fix for the underlying problem.

* Removed Poleto’s “Error executing package . . .” ImportError wrapper. We already know what package we are trying to execute, and it hasn’t actually been “executed” yet, because __init__.py failed.

* Cleaned up exception name in the “Error while finding spec” message

----------
Added file: http://bugs.python.org/file38437/issue_19771_runpy.patch.v3

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


More information about the Python-bugs-list mailing list