THRIFT-3708 NameError: global name 'TProtocol' is not defined

This closes #920
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index 4ebbe89..1ee0fcb 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -415,9 +415,15 @@
  * Prints standard thrift imports
  */
 string t_py_generator::py_imports() {
-  return gen_utf8strings_
-    ? string("from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException\nimport sys")
-    : string("from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException");
+  ostringstream ss;
+  ss << "from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, "
+        "TApplicationException"
+     << endl
+     << "from thrift.protocol.TProtocol import TProtocolException";
+  if (gen_utf8strings_) {
+    ss << endl << "import sys";
+  }
+  return ss.str();
 }
 
 /**
@@ -1011,7 +1017,7 @@
       t_field* field = (*f_iter);
       if (field->get_req() == t_field::T_REQUIRED) {
         indent(out) << "if self." << field->get_name() << " is None:" << endl;
-        indent(out) << indent_str() << "raise TProtocol.TProtocolException(message='Required field "
+        indent(out) << indent_str() << "raise TProtocolException(message='Required field "
                     << field->get_name() << " is unset!')" << endl;
       }
     }