[pypy-commit] cffi default: Strip the C line of whitespace in error reporting.
arigo
noreply at buildbot.pypy.org
Thu Oct 24 18:31:21 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r1380:e90d476329dd
Date: 2013-10-24 18:31 +0200
http://bitbucket.org/cffi/cffi/changeset/e90d476329dd/
Log: Strip the C line of whitespace in error reporting.
diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -142,7 +142,7 @@
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)
diff --git a/testing/test_parsing.py b/testing/test_parsing.py
--- a/testing/test_parsing.py
+++ b/testing/test_parsing.py
@@ -190,7 +190,7 @@
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()
More information about the pypy-commit
mailing list