Skip to content

Commit 0a760ff

Browse files
authored
Fix python tests
Fix a Python test issue exposed by OSS-fuzz integration in google/oss-fuzz#13874 I can reproduce this with the oss-fuzz build (by setting UBSan flags locally). I do not know why the issue only shows up then, but this fix is correct - the method signatures are the same as the Compact protocol factory. The factory is supposed to not be passed any argument, or the arguments that are passed should be the limits. This manifested as the below failure: ``` 2025-08-26T18:20:18.9632418Z /usr/local/bin/python test/thrift_TSerializer.py 2025-08-26T18:20:19.0144330Z .E.. 2025-08-26T18:20:19.0145197Z ====================================================================== 2025-08-26T18:20:19.0146549Z ERROR: test_TBinaryProtocolAccelerated (__main__.TestSerializer.test_TBinaryProtocolAccelerated) 2025-08-26T18:20:19.0148344Z ---------------------------------------------------------------------- 2025-08-26T18:20:19.0149187Z Traceback (most recent call last): 2025-08-26T18:20:19.0158543Z File "/src/thrift/lib/py/test/thrift_TSerializer.py", line 68, in test_TBinaryProtocolAccelerated 2025-08-26T18:20:19.0159474Z self.verify(self.binary_serialized, factory) 2025-08-26T18:20:19.0160254Z File "/src/thrift/lib/py/test/thrift_TSerializer.py", line 50, in verify 2025-08-26T18:20:19.0160914Z deserialize(Message(), serialized, factory).body, 2025-08-26T18:20:19.0161739Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2025-08-26T18:20:19.0162428Z File "/src/thrift/lib/py/build/lib.linux-x86_64-cpython-311/thrift/TSerialization.py", line 37, in deserialize 2025-08-26T18:20:19.0163082Z base.read(protocol) 2025-08-26T18:20:19.0163513Z File "/src/thrift/lib/py/gen-py/TestServer/ttypes.py", line 45, in read 2025-08-26T18:20:19.0164259Z self.body = iprot.readString().decode('utf-8', errors='replace') if sys.version_info[0] == 2 else iprot.readString() 2025-08-26T18:20:19.0164897Z ^^^^^^^^^^^^^^^^^^ 2025-08-26T18:20:19.0165620Z File "/src/thrift/lib/py/build/lib.linux-x86_64-cpython-311/thrift/protocol/TProtocol.py", line 179, in readString 2025-08-26T18:20:19.0166301Z return self.readBinary().decode('utf-8') 2025-08-26T18:20:19.0166624Z ^^^^^^^^^^^^^^^^^ 2025-08-26T18:20:19.0167302Z File "/src/thrift/lib/py/build/lib.linux-x86_64-cpython-311/thrift/protocol/TBinaryProtocol.py", line 234, in readBinary 2025-08-26T18:20:19.0167990Z self._check_string_length(size) 2025-08-26T18:20:19.0168745Z File "/src/thrift/lib/py/build/lib.linux-x86_64-cpython-311/thrift/protocol/TBinaryProtocol.py", line 48, in _check_string_length 2025-08-26T18:20:19.0169531Z self._check_length(self.string_length_limit, length) 2025-08-26T18:20:19.0170268Z File "/src/thrift/lib/py/build/lib.linux-x86_64-cpython-311/thrift/protocol/TProtocol.py", line 57, in _check_length 2025-08-26T18:20:19.0170906Z if limit is not None and length > limit: 2025-08-26T18:20:19.0171360Z ^^^^^^^^^^^^^^ 2025-08-26T18:20:19.0171764Z TypeError: '>' not supported between instances of 'int' and 'TBufferedTransport' 2025-08-26T18:20:19.0172088Z 2025-08-26T18:20:19.0172231Z ---------------------------------------------------------------------- ```
1 parent 72a714e commit 0a760ff

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/py/test/thrift_TSerializer.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,11 @@ def verify(self, serialized, factory):
5656
self.assertRaises(EOFError, deserialize, Message(), b'', factory)
5757

5858
def test_TBinaryProtocol(self):
59-
buf = TTransport.TMemoryBuffer()
60-
transport = TTransport.TBufferedTransportFactory().getTransport(buf)
61-
factory = TBinaryProtocolFactory(transport)
59+
factory = TBinaryProtocolFactory()
6260
self.verify(self.binary_serialized, factory)
6361

6462
def test_TBinaryProtocolAccelerated(self):
65-
buf = TTransport.TMemoryBuffer()
66-
transport = TTransport.TBufferedTransportFactory().getTransport(buf)
67-
factory = TBinaryProtocolAcceleratedFactory(transport)
63+
factory = TBinaryProtocolAcceleratedFactory()
6864
self.verify(self.binary_serialized, factory)
6965

7066
def test_TCompactProtocol(self):

0 commit comments

Comments
 (0)