#30324 closed Bug (fixed)
UnicodeDecodeError when loading debug templates.
Reported by: | chihun-jang | Owned by: | Nick Pope |
---|---|---|---|
Component: | Error reporting | Version: | 2.2 |
Severity: | Release blocker | Keywords: | runserver, UnicodeDecodeError, cp949, template, technical_500 |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
While studying Django, I had an error where the technical_500.html page was not properly printed.
In the log window, UnicodeDecodeError was continuously printed, and in the template, the sentence 'A server error occured. Please contact the administrator' was printed
So when I checked the technical_500.html file of Django 2.2version, I found that the dotdotdot wrapped by the <span>tag on the 239th line was changed to ellipsis.
Apparently, the version of Django 2.1.8 was a dotdotdot.
So I took steps to change the 239th line's ellipsis to dotdotdot.
Or, when reading the technical_500.html file from inside the debug.py file, the encoding format was set to utf-8.
This enabled me to resolve the error.
Did you intentionally modify the technical_html file?
Change History (9)
comment:3 by , 6 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:4 by , 6 years ago
Easy pickings: | unset |
---|---|
Has patch: | set |
Owner: | changed from | to
Summary: | I found an error related to Unicode. → UnicodeDecodeError when loading debug templates. |
Triage Stage: | Unreviewed → Accepted |
comment:5 by , 6 years ago
Severity: | Normal → Release blocker |
---|
Upgrading to Release Blocker. Thanks for the report!
comment:7 by , 6 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:11 by , 6 years ago
<li onclick="toggle('pre{{ frame.id }}', 'post{{ frame.id }}')"><pre>{{ frame.context_line }}</pre>{% if not is_email %} <span>…</span>{% endif %}</li>
On line 239, there is a special characters "…", or you can replace it with "..."
The issue here is that reading the various debug templates was changed in ea542a9 to bypass the template loaders. The template loaders use the encoding specified on the template engine which is utf-8 by default. Later in 50b8493 an ellipsis was added and this caused things to blow up on Windows as
locale.getpreferredencoding(False)
is not utf-8.Here is an alternative PR that adds tests and a release note for 2.2.1 as this is a regression.