From a7fc092ee1e0f77b818b0e4bcc8954f9f746b21a Mon Sep 17 00:00:00 2001 From: David Reiss Date: Sat, 7 Feb 2009 02:37:09 +0000 Subject: [PATCH] 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 --- compiler/cpp/src/generate/t_py_generator.cc | 9 ++++----- test/DebugProtoTest.thrift | 4 ++++ test/py/TestSyntax.py | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc index 02370565..4b3e9d98 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::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(); } diff --git a/test/DebugProtoTest.thrift b/test/DebugProtoTest.thrift index e730b22e..3adaf0c8 100644 --- a/test/DebugProtoTest.thrift +++ b/test/DebugProtoTest.thrift @@ -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 diff --git a/test/py/TestSyntax.py b/test/py/TestSyntax.py index 29214194..7e499892 100755 --- a/test/py/TestSyntax.py +++ b/test/py/TestSyntax.py @@ -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 -- 2.17.1