You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2017/09/26 00:11:54 UTC
thrift git commit: THRIFT-4206: Fix decoding of strings in containers
with py:dynamic and py:utf8strings Client: py
Repository: thrift
Updated Branches:
refs/heads/master 48ba736a5 -> 2d1fe88db
THRIFT-4206: Fix decoding of strings in containers with py:dynamic and py:utf8strings
Client: py
_read_by_ttype and _write_by_ttype must be using the *element* spec
and not the container spec when determining the correct read/write
handler.
This closes #1273
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/2d1fe88d
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/2d1fe88d
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/2d1fe88d
Branch: refs/heads/master
Commit: 2d1fe88db3f02c0a3a8f9cc2ad2f5f7881a0eae3
Parents: 48ba736
Author: Elvis Pranskevichus <el...@pinterest.com>
Authored: Tue May 23 11:36:23 2017 -0400
Committer: James E. King, III <jk...@apache.org>
Committed: Mon Sep 25 17:11:33 2017 -0700
----------------------------------------------------------------------
lib/py/src/protocol/TProtocol.py | 4 ++--
test/py/FastbinaryTest.py | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/2d1fe88d/lib/py/src/protocol/TProtocol.py
----------------------------------------------------------------------
diff --git a/lib/py/src/protocol/TProtocol.py b/lib/py/src/protocol/TProtocol.py
index f29c58d..fd20cb7 100644
--- a/lib/py/src/protocol/TProtocol.py
+++ b/lib/py/src/protocol/TProtocol.py
@@ -268,7 +268,7 @@ class TProtocolBase(object):
return self._TTYPE_HANDLERS[ttype] if ttype < len(self._TTYPE_HANDLERS) else (None, None, False)
def _read_by_ttype(self, ttype, spec, espec):
- reader_name, _, is_container = self._ttype_handlers(ttype, spec)
+ reader_name, _, is_container = self._ttype_handlers(ttype, espec)
if reader_name is None:
raise TProtocolException(type=TProtocolException.INVALID_DATA,
message='Invalid type %d' % (ttype))
@@ -389,7 +389,7 @@ class TProtocolBase(object):
self.writeStructEnd()
def _write_by_ttype(self, ttype, vals, spec, espec):
- _, writer_name, is_container = self._ttype_handlers(ttype, spec)
+ _, writer_name, is_container = self._ttype_handlers(ttype, espec)
writer_func = getattr(self, writer_name)
write = (lambda v: writer_func(v, espec)) if is_container else writer_func
for v in vals:
http://git-wip-us.apache.org/repos/asf/thrift/blob/2d1fe88d/test/py/FastbinaryTest.py
----------------------------------------------------------------------
diff --git a/test/py/FastbinaryTest.py b/test/py/FastbinaryTest.py
index db3ef8b..d231abf 100755
--- a/test/py/FastbinaryTest.py
+++ b/test/py/FastbinaryTest.py
@@ -85,6 +85,10 @@ hm.big[1].a_bite = 0x22
hm.contain.add(("and a one", "and a two"))
hm.contain.add(("then a one, two", "three!", "FOUR!"))
+if sys.version_info[0] == 2 and os.environ.get('THRIFT_TEST_PY_NO_UTF8STRINGS'):
+ hm.contain.add((u"\xd7\n\a\t".encode('utf8'),))
+else:
+ hm.contain.add((u"\xd7\n\a\t",))
hm.contain.add(())
hm.bonks["nothing"] = []