[issue25791] Raise an ImportWarning when __spec__.parent/__package__ isn't defined for a relative import

Stefan Behnel report at bugs.python.org
Mon Jun 26 17:50:10 EDT 2017


Stefan Behnel added the comment:

Sorry for not responding, missed the message, it seems.

Cython has to support old-style relative imports also in Py3 because that's how the user code was originally written, using Py2-style syntax and semantics. Most Cython code has not been converted to Py3 syntax/semantics, but still needs to work in Py3.

>From a user perspective, it's best to switch on "__future__.absolute_import" and use explicit relative imports (or write Py3 code), because it reduces the overhead at import time.

I'm hoping to look into multi-step module initialisation this summer. As Nick noted, this might also help with this issue.

----------

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


More information about the Python-bugs-list mailing list