Merging EOFException changes from Ben Maurer

Summary: Throw a proper EOFError in this case. Long term we want to change this to properly fit into the Thrift TException heirarchy with a good way to handle the original exception as well. For now, Ben is the primary user of this so we'll go ahead with his patch.

Reviewed By: mcslee

Test Plan: Included in test/py/TestEof.py


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665365 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/py/src/protocol/fastbinary.c b/lib/py/src/protocol/fastbinary.c
index 61ccd8f..3b7b5c0 100644
--- a/lib/py/src/protocol/fastbinary.c
+++ b/lib/py/src/protocol/fastbinary.c
@@ -684,6 +684,9 @@
 static bool
 checkTypeByte(DecodeBuffer* input, TType expected) {
   TType got = readByte(input);
+  if (INT_CONV_ERROR_OCCURRED(got)) {
+    return false;
+  }
 
   if (expected != got) {
     PyErr_SetString(PyExc_TypeError, "got wrong ttype while reading field");
@@ -829,11 +832,16 @@
     StructItemSpec parsedspec;
 
     type = readByte(input);
+    if (type == -1) {
+      return false;
+    }
     if (type == T_STOP) {
       break;
     }
     tag = readI16(input);
-
+    if (INT_CONV_ERROR_OCCURRED(tag)) {
+      return false;
+    }
     if (tag >= 0 && tag < spec_seq_len) {
       item_spec = PyTuple_GET_ITEM(spec_seq, tag);
     } else {