diff --git a/jedi/evaluate/compiled/__init__.py b/jedi/evaluate/compiled/__init__.py index d03d66e0..66a058a7 100644 --- a/jedi/evaluate/compiled/__init__.py +++ b/jedi/evaluate/compiled/__init__.py @@ -322,7 +322,14 @@ def load_module(path, name): sys_path.insert(0, p) temp, sys.path = sys.path, sys_path - __import__(dotted_path) + try: + __import__(dotted_path) + except RuntimeError: + if 'PySide' in dotted_path or 'PyQt' in dotted_path: + # RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap + # the QObject class. + # See https://github.com/davidhalter/jedi/pull/483 + return None # Just access the cache after import, because of #59 as well as the very # complicated import structure of Python. module = sys.modules[dotted_path] diff --git a/jedi/evaluate/imports.py b/jedi/evaluate/imports.py index a1ceb330..0c77494e 100644 --- a/jedi/evaluate/imports.py +++ b/jedi/evaluate/imports.py @@ -190,6 +190,9 @@ class ImportWrapper(pr.Base): analysis.add(self._evaluator, 'import-error', e.name_part) return [] + if module is None: + return [] + if self.import_stmt.is_nested() and not self.nested_resolve: scopes = [NestedImportModule(module, self.import_stmt)] else: