From: Robert Bradshaw Date: Mon, 28 Apr 2008 20:13:04 +0000 (-0700) Subject: 2.3 compatability, error message tests X-Git-Tag: 0.9.6.14~10 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5ac3fb638166b1a90e4d7b9edfca1feffd812369;p=cython.git 2.3 compatability, error message tests --- diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py index cda1b750..22da73f4 100644 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@ -150,11 +150,12 @@ class Context: name = source_filename.decode(filename_encoding) try: - s = PyrexScanner(f, name, source_encoding = f.encoding, - type_names = type_names, context = self) - tree = Parsing.p_module(s, pxd, full_module_name) - except UnicodeDecodeError, msg: - error((name, 0, 0), "Decoding error, set coding= at top of source (%s)" % msg) + try: + s = PyrexScanner(f, name, source_encoding = f.encoding, + type_names = type_names, context = self) + tree = Parsing.p_module(s, pxd, full_module_name) + except UnicodeDecodeError, msg: + error((name, 0, 0), "Decoding error, missing or incorrect coding= at top of source (%s)" % msg) finally: f.close() if Errors.num_errors > 0: diff --git a/tests/errors/encoding.pyx b/tests/errors/encoding.pyx new file mode 100644 index 00000000..d0c7fbe5 --- /dev/null +++ b/tests/errors/encoding.pyx @@ -0,0 +1,9 @@ +# coding=ASCII + +""" +Trs bien. +""" + +_ERRORS = """ +0:0:Decoding error, missing or incorrect coding= at top of source ('ascii' codec can't decode byte 0x8f in position 22: ordinal not in range(128)) +""" diff --git a/tests/errors/void_as_arg.pyx b/tests/errors/void_as_arg.pyx new file mode 100644 index 00000000..23717f1c --- /dev/null +++ b/tests/errors/void_as_arg.pyx @@ -0,0 +1,6 @@ +cdef extern from *: + void foo(void) + +_ERRORS = """ +2:13:Use spam() rather than spam(void) to declare a function with no arguments. +"""