forked from VimPlug/jedi
Cleanup the namespace lookups so that it also works for Python 3.7
This commit is contained in:
+10
-15
@@ -35,23 +35,18 @@ class DummyFile(object):
|
|||||||
|
|
||||||
|
|
||||||
def find_module_py34(string, path=None, full_name=None):
|
def find_module_py34(string, path=None, full_name=None):
|
||||||
implicit_namespace_pkg = False
|
|
||||||
spec = None
|
spec = None
|
||||||
loader = None
|
loader = None
|
||||||
|
|
||||||
spec = importlib.machinery.PathFinder.find_spec(string, path)
|
spec = importlib.machinery.PathFinder.find_spec(string, path)
|
||||||
if hasattr(spec, 'origin'):
|
if spec is not None:
|
||||||
origin = spec.origin
|
# We try to disambiguate implicit namespace pkgs with non implicit namespace pkgs
|
||||||
implicit_namespace_pkg = origin == 'namespace'
|
if not spec.has_location:
|
||||||
|
full_name = string if not path else full_name
|
||||||
|
implicit_ns_info = ImplicitNSInfo(full_name, spec.submodule_search_locations._path)
|
||||||
|
return None, implicit_ns_info, False
|
||||||
|
|
||||||
# We try to disambiguate implicit namespace pkgs with non implicit namespace pkgs
|
# we have found the tail end of the dotted path
|
||||||
if implicit_namespace_pkg:
|
|
||||||
full_name = string if not path else full_name
|
|
||||||
implicit_ns_info = ImplicitNSInfo(full_name, spec.submodule_search_locations._path)
|
|
||||||
return None, implicit_ns_info, False
|
|
||||||
|
|
||||||
# we have found the tail end of the dotted path
|
|
||||||
if hasattr(spec, 'loader'):
|
|
||||||
loader = spec.loader
|
loader = spec.loader
|
||||||
return find_module_py33(string, path, loader)
|
return find_module_py33(string, path, loader)
|
||||||
|
|
||||||
@@ -355,11 +350,11 @@ def no_unicode_pprint(dct):
|
|||||||
print(re.sub("u'", "'", s))
|
print(re.sub("u'", "'", s))
|
||||||
|
|
||||||
|
|
||||||
def print_to_stderr(string):
|
def print_to_stderr(*args):
|
||||||
if is_py3:
|
if is_py3:
|
||||||
eval("print(string, file=sys.stderr)")
|
eval("print(*args, file=sys.stderr)")
|
||||||
else:
|
else:
|
||||||
print >> sys.stderr, string
|
print >> sys.stderr, args
|
||||||
|
|
||||||
|
|
||||||
def utf8_repr(func):
|
def utf8_repr(func):
|
||||||
|
|||||||
Reference in New Issue
Block a user