fix Py3 encoding problem

Fix for python 3.6
>>>str(b'123')
>>>"b'123'"
>>>str(b'123', encoding='utf-8')
>>>"123"
This commit is contained in:
Igor MSK
2020-03-24 22:33:41 +03:00
committed by GitHub
parent fa6e9b1caf
commit 041ec3c63c

View File

@@ -84,7 +84,7 @@ def custom_json(o):
elif isinstance(o, decimal.Decimal):
return float(o)
elif isinstance(o, (bytes, bytearray)):
return str(o)
return str(o) if harattr(str, 'decode') else str(o, encoding='utf-8')
elif isinstance(o, lazyT):
return str(o)
elif isinstance(o, XmlComponent):