Author brett.cannon
Recipients brett.cannon, eric.snow, ncoghlan
Date 2015-12-03.20:48:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1449175692.43.0.67090220632.issue25791@psf.upfronthosting.co.za>
In-reply-to
Content
When you do a relative import, __package__ is used to help resolve it, but if it isn't defined we fall back on using __name__ and __path__. We should probably consider raising an ImportWarning if __package__ isn't defined so that some day we can consider cleaning up __import__ and its call signature to be a bit more sane and drop the `globals` argument. It would also help people catch errors where they went overboard deleting attributes off a module.

We should probably even extend it to start using __spec__.parent and then falling back to __package__, and only after both are found missing do we raise the ImportWarning about needing to use __name__ and __path__. That way __import__ can simply start taking in the spec of the calling module to do all of its work instead of having to pass all of globals().
History
Date User Action Args
2015-12-03 20:48:12brett.cannonsetrecipients: + brett.cannon, ncoghlan, eric.snow
2015-12-03 20:48:12brett.cannonsetmessageid: <1449175692.43.0.67090220632.issue25791@psf.upfronthosting.co.za>
2015-12-03 20:48:12brett.cannonlinkissue25791 messages
2015-12-03 20:48:12brett.cannoncreate