Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-2642

Recursive structs don't work in python

    XMLWordPrintableJSON

    Details

      Description

      Recursive structs in 0.9.2 work fine in c++ & c#, but not in python, because generated code trying to use objects which not constructed yet.

      Struct:

      struct Recursive {
      1: list<Recursive> Children
      }
      

      Python code:

      class Recursive:
        thrift_spec = (
          None, # 0
          (1, TType.LIST, 'Children', (TType.STRUCT,(Recursive, Recursive.thrift_spec)), None, ), # 1
        )
      

      Error message:

      Traceback (most recent call last):
        File "ttypes.py", line 20, in <module>
          class Recursive:
        File "ttypes.py", line 28, in Recursive
          (1, TType.LIST, 'Children', (TType.STRUCT,(Recursive, Recursive.thrift_spec)), None, ), # 1
      NameError: name 'Recursive' is not defined
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                econner724 Eric Conner
                Reporter:
                isanych Igor Kostenko
              • Votes:
                6 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: