Thriftpy / thriftpy2

Pure python approach of Apache Thrift.
MIT License
568 stars 90 forks source link

some times thriftpy2 parse thrift error when run #75

Closed CharellKing closed 4 years ago

CharellKing commented 5 years ago

123

BaseResp is a class, but analyze as a string.

sometimes it's ok and parse as a TMetaPayload class, but some times analyze a string.

CharellKing commented 5 years ago

from thriftpy2.parser import parse_fp thrift_meta = parse_fp(StringIO(self.thrift_idl), self.service + "_thrift").__thrift_meta__

i use parse_fp to parser idl to specs

ethe commented 5 years ago

How can I reproduce it?

CharellKing commented 5 years ago

enum DD { DD1 = 0, DD2 = 1, }

enum EE { EE1 = 0, EE2 = 1, EE3 = 2, }

struct FF { 1:required string FF1 2:required string FF2 3:optional i64 FF3 4:required string FF4 5:required i64 FF5 6:required string FF6 7:required bool FF7 8:required DD FF8 9:optional i32 FF9 10:optional string FF10 11:optional string FF11

12:optional string FF12 = ""
13:optional i32 FF13 = EE.EE1

255: optional BB BB

}

struct GG { 1:required i32 GG1 2:required string GG2 3:required string GG3

255: optional CC EE1

}

service II { GG JJ(1:FF req) }

struct AA { 1: bool AA1 = false, 2: string AA2 = "", }

struct BB { 1: string BB1 = "", 2: string BB2 = "", 3: string BB3 = "", 4: string BB4 = "", 5: optional AA BB5, 6: optional map<string, string> BB6, }

struct CC { 1: string CC1 = "", 2: i32 CC2 = 0, }

CharellKing commented 5 years ago

CC、BB、AA is defined after service

ethe commented 4 years ago

image A special code in your content, please remove it then it works.