diff options
Diffstat (limited to 'module/lib/thrift/protocol/TCompactProtocol.py')
-rw-r--r-- | module/lib/thrift/protocol/TCompactProtocol.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/module/lib/thrift/protocol/TCompactProtocol.py b/module/lib/thrift/protocol/TCompactProtocol.py index fbc156a8f..280b54f0f 100644 --- a/module/lib/thrift/protocol/TCompactProtocol.py +++ b/module/lib/thrift/protocol/TCompactProtocol.py @@ -52,8 +52,9 @@ def readVarint(trans): shift += 7 class CompactType: - TRUE = 1 - FALSE = 2 + STOP = 0x00 + TRUE = 0x01 + FALSE = 0x02 BYTE = 0x03 I16 = 0x04 I32 = 0x05 @@ -65,7 +66,8 @@ class CompactType: MAP = 0x0B STRUCT = 0x0C -CTYPES = {TType.BOOL: CompactType.TRUE, # used for collection +CTYPES = {TType.STOP: CompactType.STOP, + TType.BOOL: CompactType.TRUE, # used for collection TType.BYTE: CompactType.BYTE, TType.I16: CompactType.I16, TType.I32: CompactType.I32, @@ -75,7 +77,7 @@ CTYPES = {TType.BOOL: CompactType.TRUE, # used for collection TType.STRUCT: CompactType.STRUCT, TType.LIST: CompactType.LIST, TType.SET: CompactType.SET, - TType.MAP: CompactType.MAP, + TType.MAP: CompactType.MAP } TTYPES = {} @@ -196,11 +198,15 @@ class TCompactProtocol(TProtocolBase): def writeBool(self, bool): if self.state == BOOL_WRITE: - self.__writeFieldHeader(types[bool], self.__bool_fid) + if bool: + ctype = CompactType.TRUE + else: + ctype = CompactType.FALSE + self.__writeFieldHeader(ctype, self.__bool_fid) elif self.state == CONTAINER_WRITE: self.__writeByte(int(bool)) else: - raise AssertetionError, "Invalid state in compact protocol" + raise AssertionError, "Invalid state in compact protocol" writeByte = writer(__writeByte) writeI16 = writer(__writeI16) @@ -285,9 +291,8 @@ class TCompactProtocol(TProtocolBase): return (name, type, seqid) def readMessageEnd(self): - assert self.state == VALUE_READ + assert self.state == CLEAR assert len(self.__structs) == 0 - self.state = CLEAR def readStructBegin(self): assert self.state in (CLEAR, CONTAINER_READ, VALUE_READ), self.state |