Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12649 - more helpful Unicode exceptions for CSRF migration hel…

…per script

Thanks akaihola



git-svn-id: http://code.djangoproject.com/svn/django/trunk@12266 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1af45dc7bc711cd62867712c998e95c117999d43 1 parent 5cd4c3e
Luke Plant authored

Showing 1 changed file with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. 7  extras/csrf_migration_helper.py
7  extras/csrf_migration_helper.py
@@ -176,7 +176,12 @@ def content(self):
176 176
             return self._content
177 177
         except AttributeError:
178 178
             fd = open(self.absolute_filename)
179  
-            content = fd.read().decode(TEMPLATE_ENCODING)
  179
+            try:
  180
+                content = fd.read().decode(TEMPLATE_ENCODING)
  181
+            except UnicodeDecodeError, e:
  182
+                message = '%s in %s' % (
  183
+                    e[4], self.absolute_filename.encode('UTF-8', 'ignore'))
  184
+                raise UnicodeDecodeError(*(e.args[:4] + (message,)))
180 185
             fd.close()
181 186
             self._content = content
182 187
             return content

0 notes on commit 1af45dc

Please sign in to comment.
Something went wrong with that request. Please try again.