Repository: thrift Updated Branches: refs/heads/master a8c74d5c5 -> 8551f3f53
Revert part of 7f404fdef23dbbe5204d35bcb9261ff50939f31f unichr does not work for code point > 0x10000 on ucs2 build Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/8551f3f5 Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/8551f3f5 Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/8551f3f5 Branch: refs/heads/master Commit: 8551f3f53dee2a879de0aa511471f0190b1fe71c Parents: a8c74d5 Author: Nobuaki Sukegawa <[email protected]> Authored: Sun Nov 15 16:33:14 2015 +0900 Committer: Nobuaki Sukegawa <[email protected]> Committed: Sun Nov 15 16:33:55 2015 +0900 ---------------------------------------------------------------------- lib/py/src/protocol/TJSONProtocol.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/8551f3f5/lib/py/src/protocol/TJSONProtocol.py ---------------------------------------------------------------------- diff --git a/lib/py/src/protocol/TJSONProtocol.py b/lib/py/src/protocol/TJSONProtocol.py index 7d56545..3539412 100644 --- a/lib/py/src/protocol/TJSONProtocol.py +++ b/lib/py/src/protocol/TJSONProtocol.py @@ -251,14 +251,18 @@ class TJSONProtocolBase(TProtocolBase): def _toChar(self, high, low=None): if not low: - codepoint = high + if sys.version_info[0] == 2: + return ("\\u%04x" % high).decode('unicode-escape').encode('utf-8') + else: + return chr(high) else: codepoint = (1 << 16) + ((high & 0x3ff) << 10) codepoint += low & 0x3ff - if sys.version_info[0] == 2: - return unichr(codepoint).encode('utf-8') - else: - return chr(codepoint) + if sys.version_info[0] == 2: + s = "\\U%08x" % codepoint + return s.decode('unicode-escape').encode('utf-8') + else: + return chr(codepoint) def readJSONString(self, skipContext): highSurrogate = None
