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 Greg Price, cameron, eric.snow, ncoghlan
Date 2019-12-15.12:35:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576413330.85.0.729003422309.issue36375@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2019-12-15 12:35:30ncoghlansetrecipients: + ncoghlan, cameron, eric.snow, Greg Price
2019-12-15 12:35:30ncoghlansetmessageid: <1576413330.85.0.729003422309.issue36375@roundup.psfhosted.org>
2019-12-15 12:35:30ncoghlanlinkissue36375 messages
2019-12-15 12:35:30ncoghlancreate