THRIFT-256. python: Fix inheritance of services in the same IDL file
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
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index 0237056..4b3e9d9 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -1832,12 +1832,11 @@
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();
}
diff --git a/test/DebugProtoTest.thrift b/test/DebugProtoTest.thrift
index e730b22..3adaf0c 100644
--- a/test/DebugProtoTest.thrift
+++ b/test/DebugProtoTest.thrift
@@ -82,6 +82,10 @@
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
diff --git a/test/py/TestSyntax.py b/test/py/TestSyntax.py
index 2921419..7e49989 100755
--- a/test/py/TestSyntax.py
+++ b/test/py/TestSyntax.py
@@ -6,3 +6,4 @@
# Just import these generated files to make sure they are syntactically valid
from DebugProtoTest import EmptyService
+from DebugProtoTest import Inherited