Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include with dot in string #121

Closed
aisk opened this issue Mar 2, 2020 · 3 comments · Fixed by #125
Closed

include with dot in string #121

aisk opened this issue Mar 2, 2020 · 3 comments · Fixed by #125
Labels
bug Something isn't working

Comments

@aisk
Copy link
Member

aisk commented Mar 2, 2020

animal.people.thrift:

struct People {
       1: i32 age,
       2: string name,
}

test.thrift:

include "animal.people.thrift"

typedef animal.people.People People

main.py:

import thriftpy2


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

Run it:

$ python main.py
Traceback (most recent call last):
  File "main.py", line 4, in <module>
    thriftpy2.load('./test.thrift')
  File "/Users/asaka/Codes/thriftpy2/thriftpy2/parser/__init__.py", line 33, in load
    include_dir=include_dir)
  File "/Users/asaka/Codes/thriftpy2/thriftpy2/parser/parser.py", line 588, in parse
    parser.parse(data)
  File "/Users/asaka/Codes/thriftpy2/venv/lib/python3.7/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/Users/asaka/Codes/thriftpy2/venv/lib/python3.7/site-packages/ply/yacc.py", line 1120, in parseopt_notrack
    p.callable(pslice)
  File "/Users/asaka/Codes/thriftpy2/thriftpy2/parser/parser.py", line 399, in p_ref_type
    (p[1], p.lineno(1)))
thriftpy2.parser.exc.ThriftParserError: No type found: 'people.People', at line 3

The original thrift can parse this style's thrift but thriftpy2 does not. I think this should be a bug in thriftpy2.

@aisk aisk added the bug Something isn't working label Mar 2, 2020
@aisk
Copy link
Member Author

aisk commented Mar 2, 2020

WIthout typedef, using the People type like animal.people.People or People have the same issue.

@aisk
Copy link
Member Author

aisk commented Mar 2, 2020

Took a dig on this, found there may be some confilct if we have a a.b.thrift or two file called a.thrift / b.thrift and have a include in them.

But the origin thrift do implemented this, so I think we should respect the thrift's behavior.

@ethe
Copy link
Member

ethe commented Mar 3, 2020

Yes, I think we should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants