Having the same namespace in separate thrift files generates
-------------------------------------------------------------
Key: THRIFT-515
URL: https://issues.apache.org/jira/browse/THRIFT-515
Project: Thrift
Issue Type: Bug
Components: Compiler (Python)
Reporter: Jonathan Kupferman
Priority: Minor
If there are two thrift files which use the same namespace the generated python
code does not work. A sample case is the two thrift files provided below:
--------test.thrift----------
namespace py Sample
struct Name {
1: string n
}
struct User {
1: i32 id,
2: Name user_name
}
-------- end test.thrift----------
--------test_service.thrift-----------
include "test.thrift"
namespace py Sample
service TestService {
test.User get_user(1: i64 id),
test.Name get_user_name(1: i64 id),
}
--------end test_service.thrift-----------
This happens because the ttypes for test.thrift are clobbered by the ttypes for
TestService. As a result TestService is not imported correctly.
>>> import Sample
>>> import Sample.ttypes
>>> from Sample import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "Sample/TestService.py", line 205, in <module>
class get_user_result:
File "Sample/TestService.py", line 212, in get_user_result
(0, TType.STRUCT, 'success', (Sample.ttypes.User,
Sample.ttypes.User.thrift_spec), None, ), # 0
AttributeError: 'module' object has no attribute 'User'
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.