mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 23:04:48 +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'
|
encoding = 'utf-8'
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
encoding = 'ascii'
|
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 inspect
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -36,12 +37,12 @@ def dbg(*args):
|
|||||||
frm = inspect.stack()[1]
|
frm = inspect.stack()[1]
|
||||||
mod = inspect.getmodule(frm[0])
|
mod = inspect.getmodule(frm[0])
|
||||||
if not (mod.__name__ in ignored_modules):
|
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):
|
def warning(*args):
|
||||||
if debug_function and enable_warning:
|
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):
|
def speed(name):
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ from __future__ import with_statement
|
|||||||
import sys
|
import sys
|
||||||
import itertools
|
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 common
|
||||||
from jedi import cache
|
from jedi import cache
|
||||||
from jedi import parsing_representation as pr
|
from jedi import parsing_representation as pr
|
||||||
@@ -427,7 +427,7 @@ def find_name(scope, name_str, position=None, search_global=False,
|
|||||||
# __getattr__ / __getattribute__
|
# __getattr__ / __getattribute__
|
||||||
result += check_getattr(nscope, name_str)
|
result += check_getattr(nscope, name_str)
|
||||||
debug.dbg('sfn filter "%s" in (%s-%s): %s@%s' % (name_str, scope,
|
debug.dbg('sfn filter "%s" in (%s-%s): %s@%s' % (name_str, scope,
|
||||||
nscope, result, position))
|
nscope, u(result), position))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def descriptor_check(result):
|
def descriptor_check(result):
|
||||||
|
|||||||
Reference in New Issue
Block a user