1
0
forked from VimPlug/jedi

Remove the u() unicode function

This commit is contained in:
Dave Halter
2020-07-02 10:35:39 +02:00
parent 7f67324210
commit f1366b8a74
7 changed files with 27 additions and 42 deletions

View File

@@ -134,18 +134,7 @@ class ImplicitNSInfo(object):
self.paths = paths
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', errors=errors)
return string
def cast_path(obj):
def cast_path(string):
"""
Take a bytes or str path and cast it to unicode.
@@ -156,7 +145,9 @@ def cast_path(obj):
Since this just really complicates everything and Python 2.7 will be EOL
soon anyway, just go with always strings.
"""
return u(obj, errors='replace')
if isinstance(string, bytes):
return str(string, encoding='UTF-8', errors='replace')
return string
def pickle_load(file):