fix safeunicode error for somecase

This commit is contained in:
Prodesire 2017-11-07 08:27:52 +08:00
parent 10f98068e1
commit a8f902d6a0
1 changed files with 3 additions and 8 deletions

View File

@ -18,10 +18,10 @@ def safeunicode(obj, encoding='utf-8'):
return obj
elif t is bytes:
return obj.decode(encoding)
elif t in [int, float, bool]:
return unicode(obj)
elif t is text_type:
return t
else:
return unicode(obj)
return text_type(obj)
def safestr(obj, encoding='utf-8'):
@ -42,11 +42,6 @@ def safestr(obj, encoding='utf-8'):
return str(obj)
if not PY2:
# Since Python3, utf-8 encoded strings and unicode strings are the same thing
safeunicode = safestr
iters = [list, tuple, set, frozenset]
class _hack(tuple): pass
iters = _hack(iters)