Author: dreiss
Date: Tue Mar 24 22:48:40 2009
New Revision: 758071
URL: http://svn.apache.org/viewvc?rev=758071&view=rev
Log:
THRIFT-360. python: Make fastbinary skip struct fields with the wrong type
Modified:
incubator/thrift/trunk/lib/py/src/protocol/fastbinary.c
incubator/thrift/trunk/test/ThriftTest.thrift
incubator/thrift/trunk/test/py/SerializationTest.py
Modified: incubator/thrift/trunk/lib/py/src/protocol/fastbinary.c
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/py/src/protocol/fastbinary.c?rev=758071&r1=758070&r2=758071&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/py/src/protocol/fastbinary.c (original)
+++ incubator/thrift/trunk/lib/py/src/protocol/fastbinary.c Tue Mar 24 22:48:40
2009
@@ -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);
Modified: incubator/thrift/trunk/test/ThriftTest.thrift
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/test/ThriftTest.thrift?rev=758071&r1=758070&r2=758071&view=diff
==============================================================================
--- incubator/thrift/trunk/test/ThriftTest.thrift (original)
+++ incubator/thrift/trunk/test/ThriftTest.thrift Tue Mar 24 22:48:40 2009
@@ -113,6 +113,7 @@
struct VersioningTestV1 {
1: i32 begin_in_both,
+ 3: string old_string,
12: i32 end_in_both
}
Modified: incubator/thrift/trunk/test/py/SerializationTest.py
URL:
http://svn.apache.org/viewvc/incubator/thrift/trunk/test/py/SerializationTest.py?rev=758071&r1=758070&r2=758071&view=diff
==============================================================================
--- incubator/thrift/trunk/test/py/SerializationTest.py (original)
+++ incubator/thrift/trunk/test/py/SerializationTest.py Tue Mar 24 22:48:40 2009
@@ -16,6 +16,7 @@
def setUp(self):
self.v1obj = VersioningTestV1(
begin_in_both=12345,
+ old_string='aaa',
end_in_both=54321,
)