diff options
author | Luke Plant <L.Plant.98@cantab.net> | 2010-01-20 12:54:19 +0000 |
---|---|---|
committer | Luke Plant <L.Plant.98@cantab.net> | 2010-01-20 12:54:19 +0000 |
commit | 1af45dc7bc711cd62867712c998e95c117999d43 (patch) | |
tree | 17713ec9bc07cee133acd53586228dab46104001 /extras | |
parent | 5cd4c3e5595128bc1a3f28f2e30bab2e4dd3b1b7 (diff) | |
download | django-1af45dc7bc711cd62867712c998e95c117999d43.tar.gz |
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
Diffstat (limited to 'extras')
-rw-r--r-- | extras/csrf_migration_helper.py | 7 |
1 files changed, 6 insertions, 1 deletions
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 |