ffi.new("undefined") raises confusing exception

Issue #44 resolved
Daniel Neuhäuser
created an issue

When calling ffi.new() with something that has not been defined previously, using ffi.cdef(), a confusing exception is raised.

>>> from cffi import FFI
>>> ffi = FFI()
>>> ffi.new("undefined")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/DasIch/Development/dotfiles/virtualenv/envs/benchmarking/lib/pyth
on2.7/site-packages/cffi/api.py", line 171, in new
    cdecl = self._typeof(cdecl)
  File "/Users/DasIch/Development/dotfiles/virtualenv/envs/benchmarking/lib/pyth
on2.7/site-packages/cffi/api.py", line 106, in _typeof
  File "/Users/DasIch/Development/dotfiles/virtualenv/envs/benchmarking/lib/pyth
on2.7/site-packages/cffi/cparser.py", line 193, in parse_type
    typenode = ast.ext[-1].type.args.params[0].type
AttributeError: 'ID' object has no attribute 'type'

It would be nice to have an exception that explains the actual problem.

P.S.: I tried creating a patch for this issue, however cloning the repository and running tox (after installing the requirements in a virtualenv) produced a huge amount of failures, mostly in test_verify.py. Is there anything I should be aware of when setting up a development environment for working on cffi, that I might have missed; is this a known issue or one I should report?

Comments (4)

  1. Armin Rigo

    Re running tests: you need py.test, not tox. There is a very old tox.ini that I'm removing now. More precisely, you need to run "PYTHONPATH=/path/to/root/of/cffi py.test".

  2. Log in to comment