issue #477: ModuleFinder test fixes.

This commit is contained in:
David Wilson 2019-01-23 12:44:08 +00:00
parent c443244986
commit 7ecd5d8ba3
1 changed files with 4 additions and 3 deletions

View File

@ -476,7 +476,7 @@ class ModuleFinder(object):
# else we could return junk.
return
pkgname, _, modname = str_partition(fullname, '.')
pkgname, _, modname = str_rpartition(to_text(fullname), u'.')
pkg = sys.modules.get(pkgname)
if pkg is None or not hasattr(pkg, '__file__'):
return
@ -492,7 +492,8 @@ class ModuleFinder(object):
source = fp.read()
finally:
fp.close()
if fp:
fp.close()
if isinstance(source, mitogen.core.UnicodeType):
# get_source() returns "string" according to PEP-302, which was
@ -571,7 +572,7 @@ class ModuleFinder(object):
def generate_parent_names(self, fullname):
while '.' in fullname:
fullname, _, _ = str_partition(fullname, u'.')
fullname, _, _ = str_rpartition(to_text(fullname), u'.')
yield fullname
def find_related_imports(self, fullname):