[ 
https://issues.apache.org/jira/browse/THRIFT-3783?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15230838#comment-15230838
 ] 

Jens Geyer commented on THRIFT-3783:
------------------------------------

{quote}
import A will cause error since it referenced B, which has not be defined.
{quote}

I'm not so sure here. Thrift IDL can easily handle this. Whether Python can 
handle this is another question, but Thrift per se can. 

If type B is referenced before it is defined the parser creates a typedef 
construct for it behind the scenes. That needs to be handled slightly different 
in the code generator, but that's the only difference w/regard to Thrift itself.

> python code generator dose not handle struct dependent
> ------------------------------------------------------
>
>                 Key: THRIFT-3783
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3783
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Compiler
>            Reporter: Huabin
>            Priority: Minor
>
> given thrift idl
> {code}
> struct A {
> 1: B b,
> }
> struct B {
> 1: i32 b,
> }
> {code}
> generated ttypes.py
> {code}
> 20   class A:
>  21   """
>  22   Attributes:
>  23    - b
>  24   """
>  25  
>  26   thrift_spec = (
>  27     None, # 0
>  28     (1, TType.STRUCT, 'b', (B, B.thrift_spec), None, ), # 1
>  29   )
>  30  
> {code}
> import A will cause error since it referenced B, which has not be defined.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to