[issue20123] pydoc.synopsis fails to load binary modules

R. David Murray report at bugs.python.org
Sun Jan 5 04:15:09 CET 2014


R. David Murray added the comment:

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

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20123>
_______________________________________


More information about the Python-bugs-list mailing list