1. Python CFFI
  2. Untitled project
  3. cffi

Commits

Armin Rigo  committed e90d476

Strip the C line of whitespace in error reporting.

  • Participants
  • Parent commits ab441e9
  • Branches default

Comments (0)

Files changed (2)

File cffi/cparser.py

View file
                 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)

File testing/test_parsing.py

View file
 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()