Skip to content

Commit 1af45dc

Browse files
committed
Fixed django#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
1 parent 5cd4c3e commit 1af45dc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

extras/csrf_migration_helper.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,12 @@ def content(self):
176176
return self._content
177177
except AttributeError:
178178
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,)))
180185
fd.close()
181186
self._content = content
182187
return content

0 commit comments

Comments
 (0)