forked from VimPlug/jedi
Fix the weird py__path__ behavior
This commit is contained in:
@@ -273,7 +273,13 @@ class DirectObjectAccess(object):
|
||||
return [self._create_access_path(base) for base in self._obj.__bases__]
|
||||
|
||||
def py__path__(self):
|
||||
return self._obj.__path__
|
||||
paths = getattr(self._obj, '__path__', None)
|
||||
# Avoid some weird hacks that would just fail, because they cannot be
|
||||
# used by pickle.
|
||||
if not isinstance(paths, list) \
|
||||
or not all(isinstance(p, (bytes, unicode)) for p in paths):
|
||||
return None
|
||||
return paths
|
||||
|
||||
@_force_unicode_decorator
|
||||
def get_repr(self):
|
||||
|
||||
@@ -277,7 +277,7 @@ def _create(inference_state, access_handle, parent_context, *args):
|
||||
file_io=file_io,
|
||||
string_names=string_names,
|
||||
code_lines=code_lines,
|
||||
is_package=hasattr(compiled_object, 'py__path__'),
|
||||
is_package=compiled_object.is_package,
|
||||
).as_context()
|
||||
if name is not None:
|
||||
inference_state.module_cache.add(string_names, ValueSet([module_context]))
|
||||
|
||||
@@ -83,9 +83,14 @@ class CompiledObject(Value):
|
||||
for access in self.access_handle.py__bases__()
|
||||
)
|
||||
|
||||
@CheckAttribute()
|
||||
def py__path__(self):
|
||||
return map(cast_path, self.access_handle.py__path__())
|
||||
paths = self.access_handle.py__path__()
|
||||
if paths is None:
|
||||
return None
|
||||
return map(cast_path, paths)
|
||||
|
||||
def is_package(self):
|
||||
return self.py__path__() is not None
|
||||
|
||||
@property
|
||||
def string_names(self):
|
||||
|
||||
Reference in New Issue
Block a user