This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients Yuval S, eric.snow, ncoghlan
Date 2019-10-20.12:54:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1571576040.96.0.256382430953.issue38457@roundup.psfhosted.org>
In-reply-to
Content
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)
History
Date User Action Args
2019-10-20 12:54:00ncoghlansetrecipients: + ncoghlan, eric.snow, Yuval S
2019-10-20 12:54:00ncoghlansetmessageid: <1571576040.96.0.256382430953.issue38457@roundup.psfhosted.org>
2019-10-20 12:54:00ncoghlanlinkissue38457 messages
2019-10-20 12:54:00ncoghlancreate