THRIFT-360. python: Make fastbinary skip struct fields with the wrong type
authorDavid Reiss <dreiss@apache.org>
Tue, 24 Mar 2009 22:48:40 +0000 (22:48 +0000)
committerDavid Reiss <dreiss@apache.org>
Tue, 24 Mar 2009 22:48:40 +0000 (22:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@758071 13f79535-47bb-0310-9956-ffa450edef68

lib/py/src/protocol/fastbinary.c
test/ThriftTest.thrift
test/py/SerializationTest.py

index fd20066..50ca169 100644 (file)
@@ -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);
index 7049d51..3faaa6a 100644 (file)
@@ -113,6 +113,7 @@ service SecondService
 
 struct VersioningTestV1 {
        1: i32 begin_in_both,
+       3: string old_string,
        12: i32 end_in_both
 }
 
index a99bce6..296a50a 100755 (executable)
@@ -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,
           )