importer: Don't respond to non-.py[co] imports.

This commit is contained in:
David Wilson 2017-09-27 13:58:44 +05:30
parent bcae62c682
commit 1be10575a1
1 changed files with 6 additions and 1 deletions

View File

@ -416,7 +416,12 @@ class ModuleFinder(object):
if 'six.moves' in fullname: if 'six.moves' in fullname:
# TODO: causes inspect.getsource() to explode. # TODO: causes inspect.getsource() to explode.
return return None, None, None
modpath = getattr(sys.modules[fullname], '__file__', '')
if not modpath.rstrip('co').endswith('.py'):
# Probably a native module.
return None, None, None
is_pkg = hasattr(sys.modules[fullname], '__path__') is_pkg = hasattr(sys.modules[fullname], '__path__')
try: try: