Skip to content

Commit cb293a0

Browse files
author
burivuh
authored
Merge pull request #32 from vicpopov/avoid_decoding_in_2.7
Do not decode already decoded str in python 2.7
2 parents 8a1d9d4 + 2b63dcf commit cb293a0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

snippets/pyaloha/protocol.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ class CustomEncoder(json.JSONEncoder):
145145
def default(self, obj):
146146
if hasattr(obj, '__dumpdict__'):
147147
return obj.__dumpdict__()
148-
if isinstance(obj, bytes):
148+
if not isinstance(obj, str) and isinstance(obj, bytes):
149+
# in python 2.7 str is bytes; don't decode it
149150
return obj.decode()
150151
# Let the base class default method raise the TypeError
151152
return super(CustomEncoder, self).default(obj)

0 commit comments

Comments
 (0)