Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#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.

https://2.bp.blogspot.com/-JFSh6RRcMbs/XKUCH5KmcMI/AAAAAAAA8TU/ZC-b4fJJNL0auiAtl2fDSMfBf3nAudhtACEwYBhgL/s1600/unicode%2Berror.png
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.

https://4.bp.blogspot.com/-l8Jae3-q2aY/XKUCGVUX2VI/AAAAAAAA8TU/Gv_eoeessEIoIVZ_xJMsEaO9NqpIQmLhQCEwYBhgL/s1600/diffrent%2Btext.png

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.

https://1.bp.blogspot.com/-7X1UZVMZy58/XKUCGdbtVAI/AAAAAAAA8TM/1SdjeDtkuXYt8v0Q__zYDZwvMTesvlciQCEwYBhgL/s1600/add%2Bencoding%2Boption.png

This enabled me to resolve the error.

Did you intentionally modify the technical_html file?

Change History (9)

comment:3 by chihun-jang, 5 years ago

Owner: set to chihun-jang
Status: newassigned

comment:4 by Nick Pope, 5 years ago

Easy pickings: unset
Has patch: set
Owner: changed from chihun-jang to Nick Pope
Summary: I found an error related to Unicode.UnicodeDecodeError when loading debug templates.
Triage Stage: UnreviewedAccepted

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.

comment:5 by Carlton Gibson, 5 years ago

Severity: NormalRelease blocker

Upgrading to Release Blocker. Thanks for the report!

comment:6 by Mariusz Felisiak, 5 years ago

Original ticket that describes the same issue #30303.

comment:7 by Carlton Gibson, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:8 by Carlton Gibson <carlton.gibson@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In efb257a0:

Fixed #30324 -- Forced utf-8 encoding when loading the template for the technical 500 debug page.

Regression in 50b8493.
Related to ea542a9.

comment:9 by Carlton Gibson <carlton.gibson@…>, 5 years ago

In 6b4e57d7:

Refs #30324 -- Forced utf-8 encoding when loading templates for the technical 404 debug and congrats page.

comment:10 by Carlton Gibson <carlton.gibson@…>, 5 years ago

In 9da25fb:

[2.2.x] Fixed #30324 -- Forced utf-8 encoding when loading the template for the technical 500 debug page.

Regression in 50b8493.
Related to ea542a9.

Backport of efb257a01764855a71051d5bcc7fd66c5ad6d210 from master

comment:11 by zhangplusone, 5 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 "..."

Note: See TracTickets for help on using tickets.
Back to Top