From fc532fa2c03d17b80d7b8ce765d474eed23ca635 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Mon, 28 Apr 2008 12:17:20 -0700 Subject: [PATCH] Better unicode error. --- Cython/Compiler/Main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py index d7cc583e..cda1b750 100644 --- a/Cython/Compiler/Main.py +++ b/Cython/Compiler/Main.py @@ -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= at top of source (%s)" % msg) finally: f.close() if Errors.num_errors > 0: -- 2.26.2