2.3 compatability, error message tests
authorRobert Bradshaw <robertwb@math.washington.edu>
Mon, 28 Apr 2008 20:13:04 +0000 (13:13 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Mon, 28 Apr 2008 20:13:04 +0000 (13:13 -0700)
Cython/Compiler/Main.py
tests/errors/encoding.pyx [new file with mode: 0644]
tests/errors/void_as_arg.pyx [new file with mode: 0644]

index cda1b750eaaaaf9c97dd6102d4dfb5707b0ff046..22da73f43026dca1ac889853a24743373ec436a9 100644 (file)
@@ -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=<encoding-name> 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=<encoding-name> 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 (file)
index 0000000..d0c7fbe
--- /dev/null
@@ -0,0 +1,9 @@
+# coding=ASCII
+
+"""
+Tr\8fs bien. 
+"""
+
+_ERRORS = """
+0:0:Decoding error, missing or incorrect coding=<encoding-name> 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 (file)
index 0000000..23717f1
--- /dev/null
@@ -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.
+"""