Better unicode error.
authorRobert Bradshaw <robertwb@math.washington.edu>
Mon, 28 Apr 2008 19:17:20 +0000 (12:17 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Mon, 28 Apr 2008 19:17:20 +0000 (12:17 -0700)
Cython/Compiler/Main.py

index d7cc583e0249e50bb4f524ad7f7d567782b76c7b..cda1b750eaaaaf9c97dd6102d4dfb5707b0ff046 100644 (file)
@@ -149,10 +149,12 @@ class Context:
                 filename_encoding = sys.getdefaultencoding()
             name = source_filename.decode(filename_encoding)
 
-        s = PyrexScanner(f, name, source_encoding = f.encoding,
-                         type_names = type_names, context = self)
         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)
         finally:
             f.close()
         if Errors.num_errors > 0: