diff --git a/jedi/evaluate/context/module.py b/jedi/evaluate/context/module.py index 8d4da11b..03fb0e55 100644 --- a/jedi/evaluate/context/module.py +++ b/jedi/evaluate/context/module.py @@ -186,13 +186,17 @@ class ModuleContext(TreeContext): Lists modules in the directory of this module (if this module is a package). """ - path = self._path names = {} - if path is not None and path.endswith(os.path.sep + '__init__.py'): - mods = iter_modules([os.path.dirname(path)]) - for module_loader, name, is_pkg in mods: - # It's obviously a relative import to the current module. - names[name] = SubModuleName(self, name) + try: + method = self.py__path__ + except AttributeError: + pass + else: + for path in method(): + mods = iter_modules([path]) + for module_loader, name, is_pkg in mods: + # It's obviously a relative import to the current module. + names[name] = SubModuleName(self, name) # TODO add something like this in the future, its cleaner than the # import hacks.