mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
finally fixed a unicode problem that existed for a longer time
This commit is contained in:
@@ -161,3 +161,13 @@ try:
|
||||
encoding = 'utf-8'
|
||||
except AttributeError:
|
||||
encoding = 'ascii'
|
||||
|
||||
def u(string):
|
||||
"""Cast to unicode DAMMIT!
|
||||
Written because Python2 repr always implicitly casts to a string, so we
|
||||
have to cast back to a unicode (and we now that we always deal with valid
|
||||
unicode, because we check that in the beginning).
|
||||
"""
|
||||
if not is_py3k and not isinstance(string, unicode):
|
||||
return unicode(str(string), 'UTF-8')
|
||||
return string
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from _compatibility import u
|
||||
import inspect
|
||||
import time
|
||||
|
||||
@@ -36,12 +37,12 @@ def dbg(*args):
|
||||
frm = inspect.stack()[1]
|
||||
mod = inspect.getmodule(frm[0])
|
||||
if not (mod.__name__ in ignored_modules):
|
||||
debug_function(NOTICE, 'dbg: ' + ', '.join(str(a) for a in args))
|
||||
debug_function(NOTICE, 'dbg: ' + ', '.join(u(a) for a in args))
|
||||
|
||||
|
||||
def warning(*args):
|
||||
if debug_function and enable_warning:
|
||||
debug_function(WARNING, 'warning: ' + ', '.join(str(a) for a in args))
|
||||
debug_function(WARNING, 'warning: ' + ', '.join(u(a) for a in args))
|
||||
|
||||
|
||||
def speed(name):
|
||||
|
||||
@@ -73,7 +73,7 @@ from __future__ import with_statement
|
||||
import sys
|
||||
import itertools
|
||||
|
||||
from jedi._compatibility import next, hasattr, is_py3k, unicode, reraise
|
||||
from jedi._compatibility import next, hasattr, is_py3k, unicode, reraise, u
|
||||
from jedi import common
|
||||
from jedi import cache
|
||||
from jedi import parsing_representation as pr
|
||||
@@ -427,7 +427,7 @@ def find_name(scope, name_str, position=None, search_global=False,
|
||||
# __getattr__ / __getattribute__
|
||||
result += check_getattr(nscope, name_str)
|
||||
debug.dbg('sfn filter "%s" in (%s-%s): %s@%s' % (name_str, scope,
|
||||
nscope, result, position))
|
||||
nscope, u(result), position))
|
||||
return result
|
||||
|
||||
def descriptor_check(result):
|
||||
|
||||
Reference in New Issue
Block a user