From 5ac3fb638166b1a90e4d7b9edfca1feffd812369 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Mon, 28 Apr 2008 13:13:04 -0700 Subject: [PATCH] 2.3 compatability, error message tests --- Cython/Compiler/Main.py | 11 ++++++----- tests/errors/encoding.pyx | 9 +++++++++ tests/errors/void_as_arg.pyx | 6 ++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 tests/errors/encoding.pyx create mode 100644 tests/errors/void_as_arg.pyx 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. +""" -- 2.26.2