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 r.david.murray
Recipients brett.cannon, eric.snow, larry, ncoghlan, r.david.murray, vstinner
Date 2014-01-05.03:15:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1388891709.3.0.34224301299.issue20123@psf.upfronthosting.co.za>
In-reply-to
Content
Is it the case that given a filename, it might be possible to load a module even if open(filename) fails?

I think the logic is clearer in the form where it is not pulled out into a separate helper function.  You can avoid the double check on the extension by doing:

    if filename.endswith(importlib.machinery.BYTECODE_SUFFIXES):
        loader = importlib.machinery.SourcelessFileLoader('__temp__',
                                                          filename)
    elif filename.endswith(importlib.machinery.EXTENSION_SUFFIXES):
        loader = importlib.machinery.ExtensionFileLoader('__temp__',
                                                         filename)
    else:
        loader = None

    if loader:
        xxxxx
    else:
        xxxxx
History
Date User Action Args
2014-01-05 03:15:09r.david.murraysetrecipients: + r.david.murray, brett.cannon, ncoghlan, vstinner, larry, eric.snow
2014-01-05 03:15:09r.david.murraysetmessageid: <1388891709.3.0.34224301299.issue20123@psf.upfronthosting.co.za>
2014-01-05 03:15:09r.david.murraylinkissue20123 messages
2014-01-05 03:15:09r.david.murraycreate