KeyError in typesdict when compiling
I had sent an email to the python-cffi mailing list, but this is probably better reflected as an issue.
I have an ffi object that works fine with cdefs, but does not compile correctly. The traceback looks similar to this:
Traceback (most recent call last):
File "create_panda_datatypes.py", line 494, in <module>
main()
File "create_panda_datatypes.py", line 490, in main
GLOBAL_MAX_SYSCALL_ARG_SIZE, GLOBAL_MAX_SYSCALL_ARGS)
File "create_panda_datatypes.py", line 267, in compile
ffi.compile(verbose=100)
File "/home/luke/.pyenv/versions/3.6.6/lib/python3.6/site-packages/cffi-1.14.3-py3.6-linux-x86_64.egg/cffi/api.py", line 727, in compile
compiler_verbose=verbose, debug=debug, **kwds)
File "/home/luke/.pyenv/versions/3.6.6/lib/python3.6/site-packages/cffi-1.14.3-py3.6-linux-x86_64.egg/cffi/recompiler.py", line 1567, in recompile
verbose=compiler_verbose)
File "/home/luke/.pyenv/versions/3.6.6/lib/python3.6/site-packages/cffi-1.14.3-py3.6-linux-x86_64.egg/cffi/recompiler.py", line 1448, in make_py_source
verbose)
File "/home/luke/.pyenv/versions/3.6.6/lib/python3.6/site-packages/cffi-1.14.3-py3.6-linux-x86_64.egg/cffi/recompiler.py", line 1419, in _make_c_or_py_source
recompiler.collect_step_tables()
File "/home/luke/.pyenv/versions/3.6.6/lib/python3.6/site-packages/cffi-1.14.3-py3.6-linux-x86_64.egg/cffi/recompiler.py", line 243, in collect_step_tables
self._add_missing_struct_unions()
File "/home/luke/.pyenv/versions/3.6.6/lib/python3.6/site-packages/cffi-1.14.3-py3.6-linux-x86_64.egg/cffi/recompiler.py", line 1007, in _add_missing_struct_unions
self._struct_ctx(tp, None, approxname)
File "/home/luke/.pyenv/versions/3.6.6/lib/python3.6/site-packages/cffi-1.14.3-py3.6-linux-x86_64.egg/cffi/recompiler.py", line 953, in _struct_ctx
CffiOp(op, self._typesdict[fldtype])))
KeyError: <union $23>
I wrapped this in a try/except block to print which prints missing structs/unions from the typesdict. It seems to be missing many.
caught exception with <union $24>
caught exception with <union $26>
caught exception with <union $28>
caught exception with <struct $30>
caught exception with <struct $31>
caught exception with <struct $32>
caught exception with <struct $33>
caught exception with <struct $34>
caught exception with <struct $35>
caught exception with <struct $36>
caught exception with <struct $37>
caught exception with <struct $38>
caught exception with <struct $39>
In the try catch block it oddly enough does produce a workable file for me, but I'd like to be able to get this to work on an unmodified cffi
version.
I set up a github repo to make this very easy to reproduce. There are no dependencies other than python3 and cffi.
Steps to reproduce:
- install cffi
- git clone https://github.com/lacraig2/cffi_issue
- cd cffi_issue
- python3 error_demo.py