From: Robert Bradshaw Date: Mon, 28 Apr 2008 19:17:20 +0000 (-0700) Subject: Better unicode error. X-Git-Tag: 0.9.6.14~13 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fc532fa2c03d17b80d7b8ce765d474eed23ca635;p=cython.git Better unicode error. --- 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: