Skip to content

Commit

Permalink
Fixed #12649 - more helpful Unicode exceptions for CSRF migration hel…
Browse files Browse the repository at this point in the history
…per script

Thanks akaihola



git-svn-id: http://code.djangoproject.com/svn/django/trunk@12266 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
spookylukey committed Jan 20, 2010
1 parent 5cd4c3e commit 1af45dc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion extras/csrf_migration_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ def content(self):
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
Expand Down

0 comments on commit 1af45dc

Please sign in to comment.