Commits

Armin Rigo committed e90d476

Strip the C line of whitespace in error reporting.

Comments (0)

Files changed (2)

                 if 1 <= linenum <= len(csourcelines):
                     line = csourcelines[linenum-1]
         if line:
-            msg = 'cannot parse "%s"\n%s' % (line, msg)
+            msg = 'cannot parse "%s"\n%s' % (line.strip(), msg)
         else:
             msg = 'parse error\n%s' % (msg,)
         raise api.CDefError(msg)

testing/test_parsing.py

 def test_parse_error():
     ffi = FFI()
     e = py.test.raises(CDefError, ffi.cdef, " x y z ")
-    assert re.match(r'cannot parse " x y z "\n:\d+:', str(e.value))
+    assert re.match(r'cannot parse "x y z"\n:\d+:', str(e.value))
 
 def test_cannot_declare_enum_later():
     ffi = FFI()