// Else, this is either a module or C extension.
else:
// In either case, this path must have a filetype.
filetype = os.path.splitext(pathname)[1]
if not filetype:
raise ImportError(
"Non-package module %r path %r has no filetype" % (module_name, pathname))
After Change
// In either case, this path must have a filetype.
// os.path.splitext won"t work here since we sometimes need
// to match more than just the file extension.
filetype = [filetype
for filetype in _IMPORTABLE_FILETYPE_EXTS
if pathname.endswith(filetype)]
if filetype:
// at least one extension matched,
// pick the first (longest) one
filetype = filetype[0]
else:
raise ImportError(
"Non-package module %r path %r has no filetype" % (module_name, pathname))