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
diff --git a/lib/py/src/protocol/fastbinary.c b/lib/py/src/protocol/fastbinary.c
index fd20066..50ca169 100644
--- a/lib/py/src/protocol/fastbinary.c
+++ b/lib/py/src/protocol/fastbinary.c
@@ -891,8 +891,12 @@
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 7049d51..3faaa6a 100644
--- a/test/ThriftTest.thrift
+++ b/test/ThriftTest.thrift
@@ -113,6 +113,7 @@
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 a99bce6..296a50a 100755
--- a/test/py/SerializationTest.py
+++ b/test/py/SerializationTest.py
@@ -16,6 +16,7 @@
def setUp(self):
self.v1obj = VersioningTestV1(
begin_in_both=12345,
+ old_string='aaa',
end_in_both=54321,
)