Merge pull request #483 from ColinDuquesnoy/fix_runtime_error

Fix RuntimeError: the PyQt5.QtCore and PyQt4.QtCore modules both wrap the QObject class
This commit is contained in:
Dave Halter
2014-09-29 16:07:01 +04:30
2 changed files with 11 additions and 1 deletions

View File

@@ -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]

View File

@@ -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: