diff -r 96b73b649b15 Lib/pyclbr.py --- a/Lib/pyclbr.py Tue Mar 15 23:08:44 2016 +0100 +++ b/Lib/pyclbr.py Tue Mar 15 23:52:47 2016 +0100 @@ -142,10 +142,10 @@ def _readmodule(module, path, inpackage= search_path = path + sys.path # XXX This will change once issue19944 lands. spec = importlib.util._find_spec_from_path(fullmodule, search_path) - fname = spec.loader.get_filename(fullmodule) _modules[fullmodule] = dict - if spec.loader.is_package(fullmodule): - dict['__path__'] = [os.path.dirname(fname)] + # is module a package? + if spec.submodule_search_locations is not None: + dict['__path__'] = spec.submodule_search_locations try: source = spec.loader.get_source(fullmodule) if source is None: @@ -154,6 +154,8 @@ def _readmodule(module, path, inpackage= # not Python source, can't do anything with this module return dict + fname = spec.loader.get_filename(fullmodule) + f = io.StringIO(source) stack = [] # stack of (class, indent) pairs