From 041ec3c63c57c94c520c19cc416a099a02b31acf Mon Sep 17 00:00:00 2001 From: Igor MSK Date: Tue, 24 Mar 2020 22:33:41 +0300 Subject: [PATCH] fix Py3 encoding problem Fix for python 3.6 >>>str(b'123') >>>"b'123'" >>>str(b'123', encoding='utf-8') >>>"123" --- gluon/serializers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gluon/serializers.py b/gluon/serializers.py index a1064ebc..ab1f347b 100644 --- a/gluon/serializers.py +++ b/gluon/serializers.py @@ -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):