From a528f54eeb40608e266fcb968e43b26ba57489c6 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Tue, 24 Mar 2009 22:48:40 +0000 Subject: [PATCH] THRIFT-360. python: Make fastbinary skip struct fields with the wrong type git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@758071 13f79535-47bb-0310-9956-ffa450edef68 --- lib/py/src/protocol/fastbinary.c | 8 ++++++-- test/ThriftTest.thrift | 1 + test/py/SerializationTest.py | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/py/src/protocol/fastbinary.c b/lib/py/src/protocol/fastbinary.c index fd20066b..50ca169c 100644 --- a/lib/py/src/protocol/fastbinary.c +++ b/lib/py/src/protocol/fastbinary.c @@ -891,8 +891,12 @@ decode_struct(DecodeBuffer* input, PyObject* output, PyObject* spec_seq) { return false; } if (parsedspec.type != type) { - PyErr_SetString(PyExc_TypeError, "struct field had wrong type while reading"); - return false; + if (!skip(input, type)) { + PyErr_SetString(PyExc_TypeError, "struct field had wrong type while reading and can't be skipped"); + return false; + } else { + continue; + } } fieldval = decode_val(input, parsedspec.type, parsedspec.typeargs); diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift index 7049d51c..3faaa6ab 100644 --- a/test/ThriftTest.thrift +++ b/test/ThriftTest.thrift @@ -113,6 +113,7 @@ service SecondService struct VersioningTestV1 { 1: i32 begin_in_both, + 3: string old_string, 12: i32 end_in_both } diff --git a/test/py/SerializationTest.py b/test/py/SerializationTest.py index a99bce6f..296a50a2 100755 --- a/test/py/SerializationTest.py +++ b/test/py/SerializationTest.py @@ -16,6 +16,7 @@ class AbstractTest(unittest.TestCase): def setUp(self): self.v1obj = VersioningTestV1( begin_in_both=12345, + old_string='aaa', end_in_both=54321, ) -- 2.17.1