[issue14592] old-style (level=-1) importing broken after importlib changes

Stefan Behnel report at bugs.python.org
Tue Apr 17 07:24:45 CEST 2012


Stefan Behnel <scoder at users.sourceforge.net> added the comment:

> Yeah, the fix is dead-simple, import with level=1 and if that fails import with level=0.

With one caveat: relative imports don't work outside of packages, so the
importing code has to know when it's in a package or not. Otherwise, the
relative import would raise an exception (not an ImportError).

Interesting enough, I now get this when trying it at the prompt:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: error return without exception set

----------

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


More information about the Python-bugs-list mailing list