Mathias Nisted Velling created THRIFT-4810:
----------------------------------------------
Summary: PYTHON: deserialize does not work with python.immutable
Key: THRIFT-4810
URL: https://issues.apache.org/jira/browse/THRIFT-4810
Project: Thrift
Issue Type: Bug
Reporter: Mathias Nisted Velling
Hi,
In the python thrift implementation, the thrift.TSerialization.deserialize does
not work with structs that are marked as python.immutable.
This is because deserialize(base, buf, protocol) assumes base is modified by
base.read(..), but due to the immutability, base.read(..) instead returns a a
new instance of type(base), so when deserialize returns base, it is still just
an empty object:
{code:java}
def deserialize(base,
buf,
protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()):
transport = TTransport.TMemoryBuffer(buf)
protocol = protocol_factory.getProtocol(transport)
base.read(protocol)
return base{code}
It should probably instead just return the output of base.read(..):
{code:java}
def deserialize(base,
buf,
protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()):
transport = TTransport.TMemoryBuffer(buf)
protocol = protocol_factory.getProtocol(transport)
return base.read(protocol){code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)