THRIFT-256. python: Fix inheritance of services in the same IDL file
authorDavid Reiss <dreiss@apache.org>
Sat, 7 Feb 2009 02:37:09 +0000 (02:37 +0000)
committerDavid Reiss <dreiss@apache.org>
Sat, 7 Feb 2009 02:37:09 +0000 (02:37 +0000)
The old version of type_name did not fully qualify parent service names
when they were defined in the same IDL file, but it is necessary because
they end up in different Python files.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@741833 13f79535-47bb-0310-9956-ffa450edef68

compiler/cpp/src/generate/t_py_generator.cc
test/DebugProtoTest.thrift
test/py/TestSyntax.py

index 0237056..4b3e9d9 100644 (file)
@@ -1832,12 +1832,11 @@ string t_py_generator::argument_list(t_struct* tstruct) {
 
 string t_py_generator::type_name(t_type* ttype) {
   t_program* program = ttype->get_program();
+  if (ttype->is_service()) {
+    return get_real_py_module(program) + "." + ttype->get_name();
+  }
   if (program != NULL && program != program_) {
-    if (ttype->is_service()) {
-      return get_real_py_module(program) + "." + ttype->get_name();
-    } else {
-      return get_real_py_module(program) + ".ttypes." + ttype->get_name();
-    }
+    return get_real_py_module(program) + ".ttypes." + ttype->get_name();
   }
   return ttype->get_name();
 }
index e730b22..3adaf0c 100644 (file)
@@ -82,6 +82,10 @@ service Srv {
   i32 Janky(i32 arg)
 }
 
+service Inherited extends Srv {
+  i32 identity(i32 arg)
+}
+
 service EmptyService {}
 
 // The only purpose of this thing is to increase the size of the generated code
index 2921419..7e49989 100755 (executable)
@@ -6,3 +6,4 @@ sys.path.insert(0, glob.glob('../../lib/py/build/lib.*')[0])
 
 # Just import these generated files to make sure they are syntactically valid
 from DebugProtoTest import EmptyService
+from DebugProtoTest import Inherited