Thriftpy / thriftpy2

Pure python approach of Apache Thrift.
MIT License
572 stars 91 forks source link

Invalid thrift_spec if type is used before define #105

Closed aisk closed 4 years ago

aisk commented 4 years ago

Codes to reproduce this:

test.thrift

struct Container {
    1: A field1;
    2: list<A> field2;
    3: list<map<string, A>> field3;
}

struct A {
    1: string value
}

test.py

import thriftpy2
from pprint import pprint

test_thrift = thriftpy2.load('./test.thrift')

pprint(test_thrift.Container.thrift_spec)

output:

{1: (12, 'field1', <class 'test.A'>, False),
 2: (15, 'field2', (12, <class 'test.A'>), False),
 3: (15, 'field3', (13, (11, -3)), False)}

Notice the field3, it's spec is expected to be (15, 'field3', (13, (11, <class 'test.A'>)), False) like field2.

ethe commented 4 years ago

I think it is a bug