From 52298510ed84633aea5c491ad112a3cb64af1a1b Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 29 Dec 2017 02:02:34 +0100 Subject: [PATCH] Fixing more py27 stuff --- jedi/evaluate/compiled/context.py | 18 ++++++++++-------- jedi/evaluate/stdlib.py | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/jedi/evaluate/compiled/context.py b/jedi/evaluate/compiled/context.py index 652834f9..6ae75722 100644 --- a/jedi/evaluate/compiled/context.py +++ b/jedi/evaluate/compiled/context.py @@ -171,6 +171,7 @@ class CompiledObject(Context): from jedi.evaluate.compiled import builtin_from_name if self.api_type != 'function': return + for name in self._parse_function_doc()[1].split(): try: # TODO wtf is this? this is exactly the same as the thing @@ -353,11 +354,11 @@ class CompiledObjectFilter(AbstractFilter): docstr_defaults = { - 'floating point number': 'float', - 'character': 'str', - 'integer': 'int', - 'dictionary': 'dict', - 'string': 'str', + 'floating point number': u'float', + 'character': u'str', + 'integer': u'int', + 'dictionary': u'dict', + 'string': u'str', } @@ -369,6 +370,7 @@ def _parse_function_doc(doc): TODO docstrings like utime(path, (atime, mtime)) and a(b [, b]) -> None TODO docstrings like 'tuple of integers' """ + doc = force_unicode(doc) # parse round parentheses: def func(a, (b,c)) try: count = 0 @@ -387,7 +389,7 @@ def _parse_function_doc(doc): # UnboundLocalError for undefined end in last line debug.dbg('no brackets found - no param') end = 0 - param_str = '' + param_str = u'' else: # remove square brackets, that show an optional param ( = None) def change_options(m): @@ -405,9 +407,9 @@ def _parse_function_doc(doc): param_str = param_str.replace('-', '_') # see: isinstance.__doc__ # parse return value - r = re.search('-[>-]* ', doc[end:end + 7]) + r = re.search(u'-[>-]* ', doc[end:end + 7]) if r is None: - ret = '' + ret = u'' else: index = end + r.end() # get result type, which can contain newlines diff --git a/jedi/evaluate/stdlib.py b/jedi/evaluate/stdlib.py index f21a74ff..93bbc030 100644 --- a/jedi/evaluate/stdlib.py +++ b/jedi/evaluate/stdlib.py @@ -252,7 +252,7 @@ def builtins_isinstance(evaluator, objects, types, arguments): analysis.add(lazy_context._context, 'type-error-isinstance', node, message) return ContextSet.from_iterable( - compiled.builtin_from_name(evaluator, str(b)) + compiled.builtin_from_name(evaluator, force_unicode(str(b))) for b in bool_results )