You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jens Geyer (JIRA)" <ji...@apache.org> on 2017/10/28 08:24:00 UTC

[jira] [Resolved] (THRIFT-515) Having the same namespace in separate thrift files generates non-working code

     [ https://issues.apache.org/jira/browse/THRIFT-515?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jens Geyer resolved THRIFT-515.
-------------------------------
    Resolution: Not A Problem
      Assignee: Jens Geyer

Closed, by design-

> Having the same namespace in separate thrift files generates non-working code
> -----------------------------------------------------------------------------
>
>                 Key: THRIFT-515
>                 URL: https://issues.apache.org/jira/browse/THRIFT-515
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Compiler
>            Reporter: Jonathan Kupferman
>            Assignee: Jens Geyer
>            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 was sent by Atlassian JIRA
(v6.4.14#64029)