Nick Coghlan <ncogh...@gmail.com> added the comment:

Yes, this is a design flaw in the Python 2 import system - it derives 
`__package__` from `__name__` the first time it needs the information and 
`__package__` isn't already set.

The problem was fixed for the Python 3 series by way of PEP 451, which made 
substantial changes to the way module initialisation works, allowing the import 
system to instead derive `__package__` from `__spec__` as part of module 
creation.

Depending on your reasons for being interested in this, the `importlib2` 
package may be of interest: https://pypi.org/project/importlib2/

(Judging from the version number, Eric last updated that for Python 3.5, which 
means it will include the PEP 451 behaviour)

----------
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38457>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to