You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ns...@apache.org on 2016/03/06 03:25:27 UTC

[3/5] thrift git commit: THRIFT-3708 NameError: global name 'TProtocol' is not defined

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

This closes #920


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/5fb1fda2
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/5fb1fda2
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/5fb1fda2

Branch: refs/heads/master
Commit: 5fb1fda25a44f405c991cf8e024697bd0b06eb4f
Parents: 8b791b2
Author: Nobuaki Sukegawa <ns...@apache.org>
Authored: Sat Mar 5 03:54:51 2016 +0900
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sun Mar 6 09:45:48 2016 +0900

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_py_generator.cc | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/5fb1fda2/compiler/cpp/src/generate/t_py_generator.cc
----------------------------------------------------------------------
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 @@ string t_py_generator::py_autogen_comment() {
  * 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 @@ void t_py_generator::generate_py_struct_required_validator(ofstream& out, t_stru
       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;
       }
     }