Message358421
Leaving the relationship between pickle and __name__ alone wasn't an oversight, as folks already rely on that to gracefully transition from single-file modules to multi-file packages without breaking pickle compatibility in either direction. The trick is to do a "from ._submodule import *" in the package's __init__.py (exposing all the names), and then a "__name__ = __package__" in the submodule itself.
Thus the second snippet above, as a way to port code that was specifically relying on the double import to provide pickle compatibility without risking introducing other unintended incompatibility problems. |
|
Date |
User |
Action |
Args |
2019-12-15 12:35:30 | ncoghlan | set | recipients:
+ ncoghlan, cameron, eric.snow, Greg Price |
2019-12-15 12:35:30 | ncoghlan | set | messageid: <1576413330.85.0.729003422309.issue36375@roundup.psfhosted.org> |
2019-12-15 12:35:30 | ncoghlan | link | issue36375 messages |
2019-12-15 12:35:30 | ncoghlan | create | |
|