mirror of https://github.com/flaggo/pydu.git
fix safeunicode error for somecase
This commit is contained in:
parent
10f98068e1
commit
a8f902d6a0
|
@ -18,10 +18,10 @@ def safeunicode(obj, encoding='utf-8'):
|
||||||
return obj
|
return obj
|
||||||
elif t is bytes:
|
elif t is bytes:
|
||||||
return obj.decode(encoding)
|
return obj.decode(encoding)
|
||||||
elif t in [int, float, bool]:
|
elif t is text_type:
|
||||||
return unicode(obj)
|
return t
|
||||||
else:
|
else:
|
||||||
return unicode(obj)
|
return text_type(obj)
|
||||||
|
|
||||||
|
|
||||||
def safestr(obj, encoding='utf-8'):
|
def safestr(obj, encoding='utf-8'):
|
||||||
|
@ -42,11 +42,6 @@ def safestr(obj, encoding='utf-8'):
|
||||||
return str(obj)
|
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]
|
iters = [list, tuple, set, frozenset]
|
||||||
class _hack(tuple): pass
|
class _hack(tuple): pass
|
||||||
iters = _hack(iters)
|
iters = _hack(iters)
|
||||||
|
|
Loading…
Reference in New Issue