From d7ffd39be3d830395f9ee92cce983753d6c7f702 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 5 Nov 2010 08:19:34 +0100 Subject: [PATCH] slightly more telling error message on generic syntax errors --- Cython/Compiler/Scanning.py | 6 +++++- tests/errors/cdef_syntax.pyx | 2 +- tests/errors/cpdef_syntax.pyx | 2 +- tests/errors/e2_packedstruct_T290.pyx | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cython/Compiler/Scanning.py b/Cython/Compiler/Scanning.py index 1f60f703..535333ab 100644 --- a/Cython/Compiler/Scanning.py +++ b/Cython/Compiler/Scanning.py @@ -419,7 +419,11 @@ class PyrexScanner(Scanner): if message: self.error(message) else: - self.error("Expected '%s'" % what) + if self.sy == IDENT: + found = self.systring + else: + found = self.sy + self.error("Expected '%s', found '%s'" % (what, found)) def expect_indent(self): self.expect('INDENT', diff --git a/tests/errors/cdef_syntax.pyx b/tests/errors/cdef_syntax.pyx index aad39b30..0af66101 100644 --- a/tests/errors/cdef_syntax.pyx +++ b/tests/errors/cdef_syntax.pyx @@ -6,5 +6,5 @@ cdef nogil class test: pass _ERRORS = u""" 2: 5: Expected an identifier, found 'pass' 3: 9: Empty declarator - 4:11: Expected ':' + 4:11: Expected ':', found 'class' """ diff --git a/tests/errors/cpdef_syntax.pyx b/tests/errors/cpdef_syntax.pyx index f67cd1c4..654a1fe0 100644 --- a/tests/errors/cpdef_syntax.pyx +++ b/tests/errors/cpdef_syntax.pyx @@ -5,5 +5,5 @@ cpdef nogil class test: pass _ERRORS = u""" 2: 6: cdef blocks cannot be declared cpdef 3: 6: cdef blocks cannot be declared cpdef - 3:12: Expected ':' + 3:12: Expected ':', found 'class' """ diff --git a/tests/errors/e2_packedstruct_T290.pyx b/tests/errors/e2_packedstruct_T290.pyx index ee053ee2..d5628772 100644 --- a/tests/errors/e2_packedstruct_T290.pyx +++ b/tests/errors/e2_packedstruct_T290.pyx @@ -2,5 +2,5 @@ cdef packed foo: pass _ERRORS = u""" -1:12: Expected 'struct' +1:12: Expected 'struct', found 'foo' """ -- 2.26.2