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 berdario, brett.cannon, eric.snow, ezio.melotti, ncoghlan
Date 2014-01-22.16:55:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1390409708.8.0.0176437692969.issue20321@psf.upfronthosting.co.za>
In-reply-to
Content
So those semantics have existed as long as PEP 302 has been around, which is Python 2.3 (that PEP itself is over a decade old), so changing them now would break code.

And honestly I wouldn't change it anyway. On some filesystems, stat calls are extremely costly (e.g. NFS). Even if it was only on failed imports it would still have a cost. And considering a way to stay compatible between Python 2 and 3 is to catch ImportError and then import a module whose named changed, it would still be a costly change.

Now if you personally really want the semantics you are after you could have a sys.meta_path importer which cleared out sys.path_importer_cache and tried the import again.

As for documentation, it's explained in the language reference: http://docs.python.org/3/reference/import.html#path-entry-finders . But otherwise there isn't another place unless someone writes a HOWTO on this, but that probably isn't a good thing as import is something you really should be weary of mucking with. For someone trying to import the contents of a tarfile, they would be better served by a tarfile importer than unpacking the tarfile and then adding a path to sys.path. But someone has to write that tarfile importer first. =) Maybe some day: issue #17630.
History
Date User Action Args
2014-01-22 16:55:08brett.cannonsetrecipients: + brett.cannon, ncoghlan, ezio.melotti, eric.snow, berdario
2014-01-22 16:55:08brett.cannonsetmessageid: <1390409708.8.0.0176437692969.issue20321@psf.upfronthosting.co.za>
2014-01-22 16:55:08brett.cannonlinkissue20321 messages
2014-01-22 16:55:08brett.cannoncreate