[issue18018] SystemError: Parent module '' not loaded, cannot perform relative import

Brett Cannon report at bugs.python.org
Thu Jan 14 21:27:20 EST 2016


Brett Cannon added the comment:

The problem is in Python/import.c: https://hg.python.org/cpython/file/default/Python/import.c#l1453 . While the Python code has a check that `package` is a truthy value, the accelerated C code doesn't. Adding a check that the string isn't empty or truthy should do the trick as there seems to already be a check for None earlier.

The other question is whether this should change back to ValueError for Python 2 compatibility or turn into ImportError as Chris and Eric Snow have independently suggested?

Either way I'm only going to change this in Python 3.6 since the current semantics have been this way since Python 3.3, so it's beyond the realm of regression and into fixing a design mistake.

----------
stage:  -> test needed
versions:  -Python 3.3, Python 3.4, Python 3.5

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


More information about the Python-bugs-list mailing list