From 1af45dc7bc711cd62867712c998e95c117999d43 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Wed, 20 Jan 2010 12:54:19 +0000 Subject: [PATCH] Fixed #12649 - more helpful Unicode exceptions for CSRF migration helper script Thanks akaihola git-svn-id: http://code.djangoproject.com/svn/django/trunk@12266 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- extras/csrf_migration_helper.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extras/csrf_migration_helper.py b/extras/csrf_migration_helper.py index bc352a1762..2934ca8b07 100644 --- a/extras/csrf_migration_helper.py +++ b/extras/csrf_migration_helper.py @@ -176,7 +176,12 @@ class Template(object): return self._content except AttributeError: fd = open(self.absolute_filename) - content = fd.read().decode(TEMPLATE_ENCODING) + try: + content = fd.read().decode(TEMPLATE_ENCODING) + except UnicodeDecodeError, e: + message = '%s in %s' % ( + e[4], self.absolute_filename.encode('UTF-8', 'ignore')) + raise UnicodeDecodeError(*(e.args[:4] + (message,))) fd.close() self._content = content return content