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

PYTHON: deserialize does not work with python.immutable

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.12.0
    • None
    • Python - Library
    • 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

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

            Dates

              Created:
              Updated: