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
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 @@
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 @@
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: