davidhalter / jedi

Awesome autocompletion, static analysis and refactoring library for python
http://jedi.readthedocs.io
Other
5.81k stars 508 forks source link

TypeError: Can't mix strings and bytes in path components - PY2 under PY3 #1456

Closed puremourning closed 4 years ago

puremourning commented 4 years ago

First, apologies for the absolute vagueness of this report (i don't have a minimal reproduction script, but i do have a patch, which fixes it for me (tm)).

I have a YCM environment where ycmd (thus Jedi) is being run under python 3, but the jedi enviroment is told to use a python 2.7.5 interpreter. I have found in a particular file that I frequently get failed requests with the following error: TypeError: Can't mix strings and bytes in path components

This is happening with the following backtrace:

2019-12-10 10:17:38,262 - DEBUG - pickle loaded: /usr/lib64/python2.7/os.py
2019-12-10 10:17:38,443 - DEBUG - pickle loaded: /usr/lib64/python2.7/posixpath.py
2019-12-10 10:17:38,453 - DEBUG - pickle loaded: /usr/lib64/python2.7/ntpath.py
2019-12-10 10:17:38,507 - DEBUG - pickle loaded: /usr/lib64/python2.7/os2emxpath.py
2019-12-10 10:17:38,655 - INFO - Received completion request
2019-12-10 10:17:38,656 - DEBUG - Using filetype completion: True
2019-12-10 10:17:38,664 - DEBUG - pickle loaded: /data/p4dev/users/benj/triggers_1666/util.py
2019-12-10 10:17:38,665 - ERROR - Exception from semantic completer (using general)
Traceback (most recent call last):
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/ycmd/handlers.py", line 129, in GetCompletions
    completions = filetype_completer.ComputeCandidates( request_data )
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/ycmd/completers/completer.py", line 281, in ComputeCandidates
    candidates = self._GetCandidatesFromSubclass( request_data )
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/ycmd/completers/completer.py", line 294, in _GetCandidatesFromSubclass
    raw_completions = self.ComputeCandidatesInner( request_data )
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/ycmd/completers/python/python_completer.py", line 195, in ComputeCandidatesInner
    completions = self._GetJediScript( request_data ).completions()
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/api/__init__.py", line 217, in completions
    return completion.completions()
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/api/completion.py", line 99, in completions
    completion_names = self._get_value_completions(leaf)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/api/completion.py", line 208, in _get_value_completions
    completion_names += self._trailer_completions(dot.get_previous_leaf())
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/api/completion.py", line 253, in _trailer_completions
    for filter in value.get_filters(origin_scope=user_value.tree_node):
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/value/instance.py", line 163, in get_filters
    class_value = self.get_annotated_class_object()
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/value/instance.py", line 343, in get_annotated_class_object
    return self._get_annotated_class_object() or self.class_value
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/cache.py", line 42, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/value/instance.py", line 333, in _get_annotated_class_object
    type_var_dict = infer_type_vars_for_execution(bound_method, args, all_annotations)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/gradual/annotation.py", line 275, in infer_type_vars_for_execution
    _infer_type_vars(ann, actual_value_set),
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/gradual/annotation.py", line 342, in _infer_type_vars
    value_set.merge_types_of_iterate()
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/common/value.py", line 65, in mapper
    for value in self._set
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/common/value.py", line 32, in from_sets
    for set_ in sets:
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/common/value.py", line 65, in <genexpr>
    for value in self._set
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/base_value.py", line 58, in merge_types_of_iterate
    for lazy_value in self.iterate(contextualized_node, is_async)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/common/value.py", line 32, in from_sets
    for set_ in sets:
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/base_value.py", line 58, in <genexpr>
    for lazy_value in self.iterate(contextualized_node, is_async)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/lazy_value.py", line 46, in infer
    return self.context.infer_node(self.data)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 210, in infer_node
    return infer_node(self, node)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 139, in infer_node
    return _infer_node_if_inferred(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 152, in _infer_node_if_inferred
    return _infer_node_cached(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/cache.py", line 42, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 157, in _infer_node_cached
    return _infer_node(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/debug.py", line 82, in wrapper
    return func(*args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 53, in wrapper
    return func(context, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 167, in _infer_node
    return infer_atom(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 292, in infer_atom
    return context.py__getattribute__(atom, position=position)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 43, in py__getattribute__
    names = self.goto(name_or_str, position)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 32, in goto
    names = finder.filter_name(filters, name_or_str)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/finder.py", line 37, in filter_name
    names = filter.get(string_name)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/filters.py", line 240, in get
    return [n for filter in self._filters for n in filter.get(name)]
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/filters.py", line 240, in <listcomp>
    return [n for filter in self._filters for n in filter.get(name)]
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/filters.py", line 83, in get
    **filter_kwargs
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/filters.py", line 122, in _filter
    return list(self._check_flows(names))
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/filters.py", line 137, in _check_flows
    origin_scope=self._origin_scope
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/flow_analysis.py", line 78, in reachability_check
    return _break_check(context, value_scope, first_flow_scope, node)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/flow_analysis.py", line 93, in _break_check
    reachable = _check_if(context, flow_node)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/flow_analysis.py", line 113, in _check_if
    types = context.infer_node(node)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 210, in infer_node
    return infer_node(self, node)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 139, in infer_node
    return _infer_node_if_inferred(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 152, in _infer_node_if_inferred
    return _infer_node_cached(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/cache.py", line 42, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 157, in _infer_node_cached
    return _infer_node(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/debug.py", line 82, in wrapper
    return func(*args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 53, in wrapper
    return func(context, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 200, in _infer_node
    value_set = context.infer_node(element.children[-1])
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 210, in infer_node
    return infer_node(self, node)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 139, in infer_node
    return _infer_node_if_inferred(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 152, in _infer_node_if_inferred
    return _infer_node_cached(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/cache.py", line 42, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 157, in _infer_node_cached
    return _infer_node(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/debug.py", line 82, in wrapper
    return func(*args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 53, in wrapper
    return func(context, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 167, in _infer_node
    return infer_atom(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 292, in infer_atom
    return context.py__getattribute__(atom, position=position)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 75, in py__getattribute__
    values = ValueSet.from_sets(name.infer() for name in names)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/common/value.py", line 32, in from_sets
    for set_ in sets:
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 75, in <genexpr>
    values = ValueSet.from_sets(name.infer() for name in names)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/names.py", line 237, in infer
    self.tree_name
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/plugins/__init__.py", line 21, in wrapper
    return built_functions[name](*args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/plugins/stdlib.py", line 827, in wrapper
    return func(inference_state, context, tree_name)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 712, in tree_name_to_values
    types = _remove_statements(context, node, tree_name)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 652, in _remove_statements
    return infer_expr_stmt(context, stmt, seek_name=name)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 53, in wrapper
    return func(context, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 361, in infer_expr_stmt
    return _infer_expr_stmt(context, stmt, seek_name)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/debug.py", line 82, in wrapper
    return func(*args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 393, in _infer_expr_stmt
    value_set = context.infer_node(rhs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 210, in infer_node
    return infer_node(self, node)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 139, in infer_node
    return _infer_node_if_inferred(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 152, in _infer_node_if_inferred
    return _infer_node_cached(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/cache.py", line 42, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 157, in _infer_node_cached
    return _infer_node(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/debug.py", line 82, in wrapper
    return func(*args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 53, in wrapper
    return func(context, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 180, in _infer_node
    value_set = context.infer_node(first_child)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 210, in infer_node
    return infer_node(self, node)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 139, in infer_node
    return _infer_node_if_inferred(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 152, in _infer_node_if_inferred
    return _infer_node_cached(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/cache.py", line 42, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 157, in _infer_node_cached
    return _infer_node(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/debug.py", line 82, in wrapper
    return func(*args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 53, in wrapper
    return func(context, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 167, in _infer_node
    return infer_atom(context, element)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 292, in infer_atom
    return context.py__getattribute__(atom, position=position)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 75, in py__getattribute__
    values = ValueSet.from_sets(name.infer() for name in names)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/common/value.py", line 32, in from_sets
    for set_ in sets:
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/context.py", line 75, in <genexpr>
    values = ValueSet.from_sets(name.infer() for name in names)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/names.py", line 237, in infer
    self.tree_name
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/plugins/__init__.py", line 21, in wrapper
    return built_functions[name](*args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/plugins/stdlib.py", line 827, in wrapper
    return func(inference_state, context, tree_name)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/syntax_tree.py", line 718, in tree_name_to_values
    types = imports.infer_import(context, tree_name)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/cache.py", line 42, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/imports.py", line 63, in infer_import
    _prepare_infer_import(module_context, tree_name)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/imports.py", line 128, in _prepare_infer_import
    return from_import_name, tuple(import_path), import_node.level, importer.follow()
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/imports.py", line 304, in follow
    ) for parent_module_value in value_set
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/imports.py", line 304, in <listcomp>
    ) for parent_module_value in value_set
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/__init__.py", line 115, in import_module
    sys_path, prefer_stubs=prefer_stubs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/plugins/__init__.py", line 21, in wrapper
    return built_functions[name](*args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/plugins/flask.py", line 20, in wrapper
    return callback(inference_state, import_names, module_context, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/gradual/typeshed.py", line 124, in wrapper
    parent_module_value, sys_path)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/gradual/typeshed.py", line 142, in _try_to_load_stub_cached
    _try_to_load_stub(inference_state, import_names, *args, **kwargs)
  File "/mma/users/benj/.vim/bundle/YouCompleteMe-RHEL7/third_party/ycmd/third_party/jedi_deps/jedi/jedi/inference/gradual/typeshed.py", line 166, in _try_to_load_stub
    init = os.path.join(p, *import_names) + '-stubs' + os.path.sep + '__init__.pyi'
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/posixpath.py", line 92, in join
    genericpath._check_arg_types('join', a, *p)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/genericpath.py", line 151, in _check_arg_types
    raise TypeError("Can't mix strings and bytes in path components") from None
TypeError: Can't mix strings and bytes in path components

Versions in question:

-- Client logfile: /tmp/ycm_s3i_v1u7.log
-- Server Python interpreter: /opt/rh/rh-python36/root/usr/bin/python3
*** -- Server Python version: 3.6.3 ***
-- Server has Clang support compiled in: True
-- Clang version: clang version 7.0.1 (tags/RELEASE_701/final)
-- Extra configuration file found and loaded
-- Extra configuration path: /data/p4dev/users/benj/triggers_1666/.ycm_extra_conf.py
-- Python completer debug information:
--   Python interpreter: /usr/bin/python
--   Python path: ['/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old',
 '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']
*** --   Python version: 2.7.5 ***
--   Jedi version: 0.15.2
--   Parso version: 0.5.1

But I've also tried master of Jedi and Parso.

Following the traceback, I tried the following patch, which fixed it for my particular case, but i'll be honest when i say it is certainly not canonical and I don't quite understand why it's necessary:

commit 67abd94dd4581bdb52f811f6fac28e8ca85aacba (HEAD -> master)
Author: Ben Jackson <>
Date:   Tue Dec 10 10:30:38 2019 +0000

    Fix 'TypeError: Can't mix strings and bytes in path components' when running in PY3 but using PY2 environment

diff --git a/jedi/inference/gradual/typeshed.py b/jedi/inference/gradual/typeshed.py
index b2af277d..cd892071 100644
--- a/jedi/inference/gradual/typeshed.py
+++ b/jedi/inference/gradual/typeshed.py
@@ -163,7 +163,8 @@ def _try_to_load_stub(inference_state, import_names, python_value_set,
     if len(import_names) == 1:
         # foo-stubs
         for p in sys_path:
-            init = os.path.join(p, *import_names) + '-stubs' + os.path.sep + '__init__.pyi'
+            p = cast_path( p )
+            init = os.path.join(p, *[cast_path(i) for i in import_names]) + '-stubs' + cast_path(os.path.sep) + '__init__.pyi'
             m = _try_to_load_stub_from_file(
                 inference_state,
                 python_value_set,

Again, apologies for not including a repro, but hopefully this is enough info to repro ?

davidhalter commented 4 years ago

Thanks for the report! Isn't p = cast_path( p ) good enough?

It's just kind of hard to get the Python2/Python3 conversions all correct. IMO the sys path should probably already be unicode and not bytes.

puremourning commented 4 years ago

It probably is.. I just quickly went for the cast all the things approach and didn’t reduce it cos I was at work and needed a solution :)

davidhalter commented 4 years ago

I just "fixed" it. Since this is Python 2 I don't do proper testing anymore, I pretty much just do whatever it takes to get it work. Python 2 will soon not be supported anymore.

puremourning commented 4 years ago

Thanks!