Start using a lot more unicode literals for Python 2

This commit is contained in:
Dave Halter
2017-12-24 03:11:28 +01:00
parent 1f4e0dd22e
commit 5a06ea2699
11 changed files with 22 additions and 22 deletions

View File

@@ -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