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
This commit is contained in:
parent
5cd4c3e559
commit
1af45dc7bc
|
@ -176,7 +176,12 @@ class Template(object):
|
||||||
return self._content
|
return self._content
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
fd = open(self.absolute_filename)
|
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()
|
fd.close()
|
||||||
self._content = content
|
self._content = content
|
||||||
return content
|
return content
|
||||||
|
|
Loading…
Reference in New Issue