Thriftpy / thriftpy2

Pure python approach of Apache Thrift.
MIT License
562 stars 89 forks source link

`thriftpy2.load_fp` can't load a thrift file with a include statement #285

Open aisk opened 4 weeks ago

aisk commented 4 weeks ago

In the project's tests directory:

>>> import thriftpy2
>>> f = open('addressbook.thrift')
>>> thriftpy2.load_fp(f, 'addressbook_thrift')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/asaka/Codes/thriftpy2/thriftpy2/parser/__init__.py", line 171, in load_fp
    thrift = parse_fp(source, module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/asaka/Codes/thriftpy2/thriftpy2/parser/parser.py", line 655, in parse_fp
    parser.parse(data)
  File "/Users/asaka/Codes/thriftpy2/venv/lib/python3.12/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.12/site-packages/ply/yacc.py", line 1120, in parseopt_notrack
    p.callable(pslice)
  File "/Users/asaka/Codes/thriftpy2/thriftpy2/parser/parser.py", line 58, in p_include
    raise ThriftParserError('Unexpected include statement while loading '
thriftpy2.parser.exc.ThriftParserError: Unexpected include statement while loading from file like object.