diff --git a/jedi/evaluate/context/typing.py b/jedi/evaluate/context/typing.py index dbce7034..8a71ffcd 100644 --- a/jedi/evaluate/context/typing.py +++ b/jedi/evaluate/context/typing.py @@ -3,7 +3,7 @@ We need to somehow work with the typing objects. Since the typing objects are pretty bare we need to add all the Jedi customizations to make them work as contexts. """ -from jedi._compatibility import unicode +from jedi._compatibility import unicode, force_unicode from jedi import debug from jedi.evaluate.cache import evaluator_method_cache from jedi.evaluate.compiled import builtin_from_name @@ -376,6 +376,9 @@ class TypeVarClass(_BaseTypingContext): return None else: safe_value = method(default=None) + if self.evaluator.environment.version_info.major == 2: + if isinstance(safe_value, bytes): + return force_unicode(safe_value) if isinstance(safe_value, (str, unicode)): return safe_value return None diff --git a/jedi/plugins/stdlib.py b/jedi/plugins/stdlib.py index 3319046a..bd28bb05 100644 --- a/jedi/plugins/stdlib.py +++ b/jedi/plugins/stdlib.py @@ -403,13 +403,13 @@ def collections_namedtuple(obj, arguments): # Process arguments # TODO here we only use one of the types, we should use all. # TODO this is buggy, doesn't need to be a string - name = list(_follow_param(evaluator, arguments, 0))[0].get_safe_value() + name = force_unicode(list(_follow_param(evaluator, arguments, 0))[0].get_safe_value()) _fields = list(_follow_param(evaluator, arguments, 1))[0] if isinstance(_fields, compiled.CompiledValue): - fields = _fields.get_safe_value().replace(',', ' ').split() + fields = force_unicode(_fields.get_safe_value()).replace(',', ' ').split() elif isinstance(_fields, iterable.Sequence): fields = [ - v.get_safe_value() + force_unicode(v.get_safe_value()) for lazy_context in _fields.py__iter__() for v in lazy_context.infer() if is_string(v) ]