Run test for THRIFT-2413
Slightly simplify _toChar method too.
This closes #695
diff --git a/lib/py/src/protocol/TJSONProtocol.py b/lib/py/src/protocol/TJSONProtocol.py
index d210bff..aada3fc 100644
--- a/lib/py/src/protocol/TJSONProtocol.py
+++ b/lib/py/src/protocol/TJSONProtocol.py
@@ -251,18 +251,14 @@
def _toChar(self, high, low=None):
if not low:
- if sys.version_info[0] == 2:
- return ("\\u%04x" % high).decode('unicode-escape').encode('utf-8')
- else:
- return chr(high)
+ codepoint = high
else:
codepoint = (1 << 16) + ((high & 0x3ff) << 10)
codepoint += low & 0x3ff
- if sys.version_info[0] == 2:
- s = "\\U%08x" % codepoint
- return s.decode('unicode-escape').encode('utf-8')
- else:
- return chr(codepoint)
+ if sys.version_info[0] == 2:
+ return unichr(codepoint).encode('utf-8')
+ else:
+ return chr(codepoint)
def readJSONString(self, skipContext):
highSurrogate = None