Run test for THRIFT-2413 Slightly simplify _toChar method too.
This closes #695 Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/7f404fde Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/7f404fde Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/7f404fde Branch: refs/heads/master Commit: 7f404fdef23dbbe5204d35bcb9261ff50939f31f Parents: f892674 Author: Nobuaki Sukegawa <[email protected]> Authored: Sat Nov 14 17:05:42 2015 +0900 Committer: Nobuaki Sukegawa <[email protected]> Committed: Sun Nov 15 14:00:18 2015 +0900 ---------------------------------------------------------------------- lib/py/Makefile.am | 10 ++++++---- lib/py/src/protocol/TJSONProtocol.py | 14 +++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/7f404fde/lib/py/Makefile.am ---------------------------------------------------------------------- diff --git a/lib/py/Makefile.am b/lib/py/Makefile.am index b88b6be..c0db871 100755 --- a/lib/py/Makefile.am +++ b/lib/py/Makefile.am @@ -22,13 +22,14 @@ DESTDIR ?= / if WITH_PY3 py3-build: $(PYTHON3) setup.py build +py3-test: py3-build + PYTHONPATH=build/lib $(PYTHON3) test/thrift_json.py else py3-build: +py3-test: endif -testing: - -all-local: py3-build testing +all-local: py3-build $(PYTHON) setup.py build # We're ignoring prefix here because site-packages seems to be @@ -41,7 +42,8 @@ install-exec-hook: clean-local: $(RM) -r build -check-local: all +check-local: all py3-test + PYTHONPATH=$(shell ls build/lib* -dr | head -n1) $(PYTHON) test/thrift_json.py EXTRA_DIST = \ CMakeLists.txt \ http://git-wip-us.apache.org/repos/asf/thrift/blob/7f404fde/lib/py/src/protocol/TJSONProtocol.py ---------------------------------------------------------------------- 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 @@ class TJSONProtocolBase(TProtocolBase): 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
