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 brett.cannon
Date 2015-11-17.17:07:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1447780060.32.0.735153163812.issue25649@psf.upfronthosting.co.za>
In-reply-to
Content
If you look at things like https://github.com/kennethreitz/requests/issues/2870 and https://pythonhosted.org/six/#module-six.moves you start to notice that users do on occasion have a need to alias module names. It might be worth thinking through what that might entail and provide a solution.

Historically it has been done with a meta path importer which catches the import for some old module name, imports the real name, and then sets sys.modules under the alternative name before returning that the import was successful. It's a little tricky to get right, though, since you essentially have to pause an import while another one is going on, make sure you wait to the last minute to do the sys.modules aliasing to make sure no object swap handled from underneath you. I also have not thought through the best way to do this with module specs., but maybe there is a better way. There's also making sure locking is handled properly.

The reason this might be useful to have in importlib is it would help facilitate module renamings. If you set it up so that it isn't hard to turn on with mappings of old name to new along with whether you want to raise an ImportWarning about the aliasing then others may find it useful.
History
Date User Action Args
2015-11-17 17:07:40brett.cannonsetrecipients: + brett.cannon
2015-11-17 17:07:40brett.cannonsetmessageid: <1447780060.32.0.735153163812.issue25649@psf.upfronthosting.co.za>
2015-11-17 17:07:40brett.cannonlinkissue25649 messages
2015-11-17 17:07:39brett.cannoncreate