mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-27 18:52:18 +08:00
Start using a lot more unicode literals for Python 2
This commit is contained in:
@@ -220,14 +220,14 @@ except AttributeError:
|
||||
encoding = 'ascii'
|
||||
|
||||
|
||||
def u(string):
|
||||
def u(string, errors='strict'):
|
||||
"""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 isinstance(string, bytes):
|
||||
return str(string, encoding='UTF-8')
|
||||
return unicode(string, encoding='UTF-8', errors=errors)
|
||||
return string
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user