Test failures for test_some_float_invalid_1 and in test_verify1.py

Issue #334 resolved
Hans-Peter Jansen
created an issue

Hi,

we're seeing consistently these test failures for more or less any target on openSUSE build service: https://build.opensuse.org/package/show/devel:languages:python/python-cffi

Here's an except from the build logs:

[  229s] =================================== FAILURES ===================================
[  229s] __________________________ test_some_float_invalid_1 ___________________________
[  229s] 
[  229s]     def test_some_float_invalid_1():
[  229s]         ffi = FFI()
[  229s] >       py.test.raises(FFIError, ffi.cdef, "typedef long double... foo_t;")
[  229s] 
[  229s] testing/cffi1/test_recompiler.py:1128: 
[  229s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  229s] cffi/api.py:106: in cdef
[  229s]     self._cdef(csource, override=override, packed=packed)
[  229s] cffi/api.py:120: in _cdef
[  229s]     self._parser.parse(csource, override=override, **options)
[  229s] cffi/cparser.py:308: in parse
[  229s]     self._internal_parse(csource)
[  229s] cffi/cparser.py:313: in _internal_parse
[  229s]     ast, macros, csource = self._parse(csource)
[  229s] cffi/cparser.py:271: in _parse
[  229s]     self.convert_pycparser_error(e, csource)
[  229s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  229s] 
[  229s] self = <cffi.cparser.Parser object at 0x7fa6a95e5710>
[  229s] e = ParseError(':2:35: before: foo_t',)
[  229s] csource = 'typedef int __dotdotdotint__, __dotdotdotfloat__, __dotdotdot__;\ntypedef long  __dotdotdotfloat__  foo_t;'
[  229s] 
[  229s]     def convert_pycparser_error(self, e, csource):
[  229s]         line = self._convert_pycparser_error(e, csource)
[  229s]     
[  229s]         msg = str(e)
[  229s]         if line:
[  229s]             msg = 'cannot parse "%s"\n%s' % (line.strip(), msg)
[  229s]         else:
[  229s]             msg = 'parse error\n%s' % (msg,)
[  229s] >       raise CDefError(msg)
[  229s] E       CDefError: cannot parse "typedef long  __dotdotdotfloat__  foo_t;"
[  229s] E       :2:35: before: foo_t
[  229s] 
[  229s] cffi/cparser.py:300: CDefError
[  229s] ____________________ test_unsupported_some_primitive_types _____________________
[  229s] 
[  229s]     def test_unsupported_some_primitive_types():
[  229s]         ffi = FFI()
[  229s] >       py.test.raises(FFIError, ffi.cdef, """typedef void... foo_t;""")
[  229s] 
[  229s] testing/cffi1/test_verify1.py:2212: 
[  229s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  229s] cffi/api.py:106: in cdef
[  229s]     self._cdef(csource, override=override, packed=packed)
[  229s] cffi/api.py:120: in _cdef
[  229s]     self._parser.parse(csource, override=override, **options)
[  229s] cffi/cparser.py:308: in parse
[  229s]     self._internal_parse(csource)
[  229s] cffi/cparser.py:313: in _internal_parse
[  229s]     ast, macros, csource = self._parse(csource)
[  229s] cffi/cparser.py:271: in _parse
[  229s]     self.convert_pycparser_error(e, csource)
[  229s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[  229s] 
[  229s] self = <cffi.cparser.Parser object at 0x7fa6a95bfb50>
[  229s] e = ParseError(':2:29: before: foo_t',)
[  229s] csource = 'typedef int __dotdotdotint__, __dotdotdotfloat__, __dotdotdot__;\ntypedef void __dotdotdot__  foo_t;'
[  229s] 
[  229s]     def convert_pycparser_error(self, e, csource):
[  229s]         line = self._convert_pycparser_error(e, csource)
[  229s]     
[  229s]         msg = str(e)
[  229s]         if line:
[  229s]             msg = 'cannot parse "%s"\n%s' % (line.strip(), msg)
[  229s]         else:
[  229s]             msg = 'parse error\n%s' % (msg,)
[  229s] >       raise CDefError(msg)
[  229s] E       CDefError: cannot parse "typedef void __dotdotdot__  foo_t;"
[  229s] E       :2:29: before: foo_t
[  229s] 
[  229s] cffi/cparser.py:300: CDefError

Any idea how to avoid this?

Comments (5)

  1. Armin Rigo

    I think it's very shallow. pycparser now detects a bogus syntax combination where it previously would not; I guess it left it to later stages to complain. With cffi, the effect is simply to raise CDefError instead of FFIError in these bogus cases. Fixed in b19be645c9f5. Thanks! Now all tests pass for me with pycparser 2.18.

  2. Log in to comment