forked from VimPlug/jedi
Fix some more py36 to py27 issues
This commit is contained in:
@@ -448,6 +448,8 @@ class FakeDict(_FakeArray):
|
||||
yield LazyKnownContext(compiled.create_simple_object(self.evaluator, key))
|
||||
|
||||
def py__getitem__(self, index):
|
||||
if isinstance(index, bytes):
|
||||
index = force_unicode(index)
|
||||
return self._dct[index].infer()
|
||||
|
||||
def dict_values(self):
|
||||
|
||||
@@ -269,7 +269,7 @@ class DictFilter(AbstractFilter):
|
||||
value = self._convert(name, self._dct[name])
|
||||
except KeyError:
|
||||
return []
|
||||
|
||||
else:
|
||||
return list(self._filter([value]))
|
||||
|
||||
def values(self):
|
||||
@@ -306,7 +306,12 @@ class SpecialMethodFilter(DictFilter):
|
||||
class SpecialMethodName(AbstractNameDefinition):
|
||||
api_type = u'function'
|
||||
|
||||
def __init__(self, parent_context, string_name, callable_, builtin_context):
|
||||
def __init__(self, parent_context, string_name, value, builtin_context):
|
||||
callable_, python_version = value
|
||||
if python_version is not None and \
|
||||
python_version != parent_context.evaluator.environment.version_info.major:
|
||||
raise KeyError
|
||||
|
||||
self.parent_context = parent_context
|
||||
self.string_name = string_name
|
||||
self._callable = callable_
|
||||
@@ -355,14 +360,11 @@ def has_builtin_methods(cls):
|
||||
|
||||
|
||||
def register_builtin_method(method_name, python_version_match=None):
|
||||
def wrapper(func):
|
||||
if python_version_match and python_version_match != 2 + int(is_py3):
|
||||
# Some functions do only apply to certain versions.
|
||||
return func
|
||||
def decorator(func):
|
||||
dct = func.__dict__.setdefault('registered_builtin_methods', {})
|
||||
dct[method_name] = func
|
||||
dct[method_name] = func, python_version_match
|
||||
return func
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
|
||||
def get_global_filters(evaluator, context, until_position, origin_scope):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import imp
|
||||
|
||||
from jedi._compatibility import unicode
|
||||
from jedi._compatibility import unicode, force_unicode
|
||||
from jedi.evaluate.cache import evaluator_method_cache
|
||||
from jedi.evaluate.base_context import ContextualizedNode
|
||||
from jedi.evaluate.helpers import is_string
|
||||
@@ -11,16 +11,17 @@ from jedi.evaluate.utils import ignored
|
||||
|
||||
|
||||
def _abs_path(module_context, path):
|
||||
module_path = module_context.py__file__()
|
||||
if os.path.isabs(path):
|
||||
return path
|
||||
|
||||
module_path = module_context.py__file__()
|
||||
if module_path is None:
|
||||
# In this case we have no idea where we actually are in the file
|
||||
# system.
|
||||
return None
|
||||
|
||||
base_dir = os.path.dirname(module_path)
|
||||
path = force_unicode(path)
|
||||
return os.path.abspath(os.path.join(base_dir, path))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user