thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens Geyer (JIRA)" <>
Subject [jira] [Commented] (THRIFT-2642) Recursive structs don't work in python
Date Wed, 05 Jul 2017 20:15:00 GMT


Jens Geyer commented on THRIFT-2642:

> I think that's thrift should be  working the same no matter the language (that's the
point of thrift I believe).


> disable recursive structures for everyone

Ehm, no. :)

A bit of history and background may help: This particular feature has been added based on
the impl in fbthrift, and it is one of the additions with the most impact on Thrift in my
opinion. But since Thrift's target language base is much larger compare to fbthrift, we unfortunately
do not yet have suitable support in some of them, e.g. Python. 

There are similar other features that do also not have broad language support, for several
reasons. For example, the THeader stuff is currently only available for C++. Nevertheless,
the fact that not all > 20 languages do offer it *today* does not imply that we will throw
it out. It is a cool feature, and whoever needs it for his language of choice will contribute
a patch sooner or later. That's how open source works. It doesn't have to be perfect from
the beginning (which is especially a stretching goal if there is a target language base as
large as Thrift's). 

So my favourite would be:

> make it work for Python

However I would be a bad implementor, because I very rarely use Python myself and I probably
only make it worse. But what if you two guys take a stab on it together? Could that work?
What do you think? Anyone else reading this who wants to try his luck?

> Recursive structs don't work in python
> --------------------------------------
>                 Key: THRIFT-2642
>                 URL:
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Compiler, Python - Library
>    Affects Versions: 0.9.2
>            Reporter: Igor Kostenko
> 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:
> {code}
> struct Recursive {
> 1: list<Recursive> Children
> }
> {code}
> Python code:
> {code}
> class Recursive:
>   thrift_spec = (
>     None, # 0
>     (1, TType.LIST, 'Children', (TType.STRUCT,(Recursive, Recursive.thrift_spec)), None,
), # 1
>   )
> {code}
> Error message:
> {code}
> Traceback (most recent call last):
>   File "", line 20, in <module>
>     class Recursive:
>   File "", line 28, in Recursive
>     (1, TType.LIST, 'Children', (TType.STRUCT,(Recursive, Recursive.thrift_spec)), None,
), # 1
> NameError: name 'Recursive' is not defined
> {code}

This message was sent by Atlassian JIRA

View raw message