Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Script.get_definition for gobject function fails #59

tkf opened this Issue · 2 comments

2 participants


Executing this code

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

yields this:

Traceback (most recent call last):
  File "/.../jedi/", line 1349, in follow_statement
    result = follow_call_list(call_list)
  File "/.../jedi/", line 1428, in follow_call_list
    result += follow_call(call)
  File "/.../jedi/", line 1443, in follow_call
    return follow_call_path(path, scope, position)
  File "/.../jedi/", line 1467, in follow_call_path
    result = imports.strip_imports(scopes)
  File "/.../jedi/", line 258, in strip_imports
    result += ImportPath(s).follow()
  File "/.../jedi/", line 154, in follow
    remove_star_imports(s) for s in scopes)
  File "/.../jedi/", line 154, in <genexpr>
    remove_star_imports(s) for s in scopes)
  File "/.../jedi/", line 271, in remove_star_imports
    modules = strip_imports(i for i in scope.get_imports() if
  File "/.../jedi/", line 258, in strip_imports
    result += ImportPath(s).follow()
  File "/.../jedi/", line 146, in follow
    scope, rest = self._follow_file_system()
  File "/.../jedi/", line 247, in _follow_file_system
    return f.parser.module, rest
  File "/.../jedi/", line 42, in parser
  File "/.../jedi/", line 49, in _load_module
    source = self._get_source()
  File "/.../jedi/", line 134, in _get_source
    return self._generate_code(self.module, self._load_mixins())
  File "/.../jedi/", line 129, in module
    load_module(name, path)
  File "/.../jedi/", 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'

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.


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.