Message354998
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) |
|
Date |
User |
Action |
Args |
2019-10-20 12:54:00 | ncoghlan | set | recipients:
+ ncoghlan, eric.snow, Yuval S |
2019-10-20 12:54:00 | ncoghlan | set | messageid: <1571576040.96.0.256382430953.issue38457@roundup.psfhosted.org> |
2019-10-20 12:54:00 | ncoghlan | link | issue38457 messages |
2019-10-20 12:54:00 | ncoghlan | create | |
|