1
0
forked from VimPlug/jedi

fix some python 3 compatibility things (which involves some real bugs, but py2 was passing)

This commit is contained in:
Dave Halter
2014-01-12 17:02:26 +01:00
parent e4f3f5bea2
commit c75cef0882
5 changed files with 16 additions and 17 deletions

View File

@@ -563,11 +563,10 @@ class Script(object):
match = re.match(r'^(.*?)(\.|)(\w?[\w\d]*)$', path, flags=re.S)
return match.groups()
@staticmethod
def _sorted_defs(d):
def _sorted_defs(self, d):
# Note: `or ''` below is required because `module_path` could be
# None and you can't compare None and str in Python 3.
return sorted(d, key=lambda x: (x.module_path or '', x.line, x.column))
return sorted(d, key=lambda x: (x.module_path or '', x.line or 0, x.column or 0))
class Interpreter(Script):

View File

@@ -173,11 +173,11 @@ class BaseDefinition(object):
The module name.
>>> from jedi import Script
>>> source = 'import datetime'
>>> script = Script(source, 1, len(source), 'example.py')
>>> source = 'import json'
>>> script = Script(source, path='example.py')
>>> d = script.goto_definitions()[0]
>>> print(d.module_name) # doctest: +ELLIPSIS
datetime
json
"""
return str(self._module.name)