Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Script.get_definition for gobject function fails #59

Closed
tkf opened this Issue · 2 comments

2 participants

Takafumi Arakaki Dave Halter
Takafumi Arakaki
Collaborator

Executing this code

source = """\
import gobject
gobject.idle_add"""
script = jedi.Script(source, 2, len('gobject.idle_'), '')
definitions = script.get_definition()
definitions

yields this:

Traceback (most recent call last):
  File "/.../jedi/evaluate.py", line 1349, in follow_statement
    result = follow_call_list(call_list)
  File "/.../jedi/evaluate.py", line 1428, in follow_call_list
    result += follow_call(call)
  File "/.../jedi/evaluate.py", line 1443, in follow_call
    return follow_call_path(path, scope, position)
  File "/.../jedi/evaluate.py", line 1467, in follow_call_path
    result = imports.strip_imports(scopes)
  File "/.../jedi/imports.py", line 258, in strip_imports
    result += ImportPath(s).follow()
  File "/.../jedi/imports.py", line 154, in follow
    remove_star_imports(s) for s in scopes)
  File "/.../jedi/imports.py", line 154, in <genexpr>
    remove_star_imports(s) for s in scopes)
  File "/.../jedi/imports.py", line 271, in remove_star_imports
    modules = strip_imports(i for i in scope.get_imports() if i.star)
  File "/.../jedi/imports.py", line 258, in strip_imports
    result += ImportPath(s).follow()
  File "/.../jedi/imports.py", line 146, in follow
    scope, rest = self._follow_file_system()
  File "/.../jedi/imports.py", line 247, in _follow_file_system
    return f.parser.module, rest
  File "/.../jedi/builtin.py", line 42, in parser
    self._load_module()
  File "/.../jedi/builtin.py", line 49, in _load_module
    source = self._get_source()
  File "/.../jedi/builtin.py", line 134, in _get_source
    return self._generate_code(self.module, self._load_mixins())
  File "/.../jedi/builtin.py", line 129, in module
    load_module(name, path)
  File "/.../jedi/builtin.py", line 104, in load_module
    exec_function('import %s as module' % name, content)
  File "blub", line 2, in exec_function
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute '_gobject'
Dave Halter
Owner

gobject uses something like this to import builtin libraries:

import gobject._gobject
_gobject = sys.modules['gobject._gobject']

If you want to access gobject directly: _gobject = gobject._gobject you'll get an AttributeError.
Talk about strange imports! :-D

The only remaining problem is that you don't get a definition.

Takafumi Arakaki
Collaborator

Still, not failing helps a lot. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.