forked from VimPlug/jedi
fix some python 3 compatibility things (which involves some real bugs, but py2 was passing)
This commit is contained in:
@@ -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):
|
||||
|
||||
+3
-3
@@ -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)
|
||||
|
||||
|
||||
@@ -154,6 +154,9 @@ def load_module(path, name):
|
||||
name = os.path.basename(path)
|
||||
name = name.rpartition('.')[0] # cut file type (normally .so)
|
||||
|
||||
# sometimes there are endings like `_sqlite3.cpython-32mu`
|
||||
name = re.sub(r'\..*', '', name)
|
||||
|
||||
sys_path = get_sys_path()
|
||||
if path:
|
||||
sys_path.insert(0, path)
|
||||
|
||||
@@ -45,9 +45,6 @@ def _load_fakes(module_name):
|
||||
raise NotImplementedError()
|
||||
return funcs
|
||||
|
||||
# sometimes there are stupid endings like `_sqlite3.cpython-32mu`
|
||||
module_name = re.sub(r'\..*', '', module_name)
|
||||
|
||||
if module_name == '__builtin__' and not is_py3k:
|
||||
module_name = 'builtins'
|
||||
path = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
Reference in New Issue
Block a user