[
https://issues.apache.org/jira/browse/THRIFT-3783?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15230866#comment-15230866
]
ASF GitHub Bot commented on THRIFT-3783:
----------------------------------------
Github user Jens-G commented on a diff in the pull request:
https://github.com/apache/thrift/pull/982#discussion_r58929004
--- Diff: compiler/cpp/src/generate/t_py_generator.cc ---
@@ -384,6 +406,55 @@ void t_py_generator::init_generator() {
py_autogen_comment() << endl <<
py_imports() << endl <<
"from .ttypes import *" << endl;
+
+ construct_object_dependent_graph();
+}
+
+/**
+ * Construct object dependent graph to determine object generate order
+ * if cycle dependent is detected, generate process will be aborted
+ * object dependent example
--- End diff --
But your test case is perfectly valid Thrift IDL:
```
struct A {
1: B b;
}
struct B {
1: A a;
}
```
One can do this with Thrift. Is there no way to support that in Python?
Something like forward-declaration of types maybe?
> 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)