Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4810

PYTHON: deserialize does not work with python.immutable

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 0.12.0
    • Fix Version/s: None
    • Component/s: Python - Library
    • Labels:
      None

      Description

      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:

      def deserialize(base,
                      buf,
                      protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()):
          transport = TTransport.TMemoryBuffer(buf)
          protocol = protocol_factory.getProtocol(transport)
          base.read(protocol)
          return base

       

      It should probably instead just return the output of base.read(..):

      def deserialize(base,
                      buf,
                      protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()):
          transport = TTransport.TMemoryBuffer(buf)
          protocol = protocol_factory.getProtocol(transport)
          return base.read(protocol)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              gnillev Mathias Nisted Velling
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: