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
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue