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 brett.cannon
Recipients barry, brett.cannon, eric.snow, ncoghlan, pitrou, pmpp, rhettinger
Date 2018-04-23.00:22:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
@Nick: We've had this discussion before about specs being a "receipt" of import versus not and the last time we agreed on not. :) That's why we raise a warning if __package__ doesn't match __spec__.parent:

It's documented through by saying __package__ has to match __spec__.parent. We didn't make it stronger since we can't get rid of any of these attributes until Python 2.7 compatibility is no longer a concern. And I believe __package__/__spec__.parent is the only attribute whose data is in any way directly relied on in importlib which is being proposed for removal (e.g. __file__, __cached__, and __loader__ are just recorded).

@Raymond: Thanks for the teaching info. I actually opened this after running dir() on a module and having there be just as many module-related attributes as defined attributes.

@Antoine: we can keep __file__ if necessary (I was on the fence about keeping it to begin with). But as Barry pointed out, bugs have occurred because we now have two places for most of these details and people don't always know which one to update.

@Barry: the tricky bit is what to do if someone sets their own __getattr__() on a module? E.g. I just published modutil which provides a __getattr__ for lazy importing, so users of this would need a way to not have either function get stomped on by the other.
Date User Action Args
2018-04-23 00:22:12brett.cannonsetrecipients: + brett.cannon, barry, rhettinger, ncoghlan, pitrou, pmpp, eric.snow
2018-04-23 00:22:11brett.cannonsetmessageid: <>
2018-04-23 00:22:11brett.cannonlinkissue33277 messages
2018-04-23 00:22:09brett.cannoncreate