Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#23946 closed Bug (fixed)

Runserver socket error in unicode fails to print error message

Reported by: Andriy Sokolovskiy Owned by: Andriy Sokolovskiy
Component: Core (Management commands) Version: master
Severity: Normal Keywords: unicode, runserver, management command
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 (last modified by Andriy Sokolovskiy)

In django.core.management.commands.runserver.Command#inner_run, when catching socket error, can be a unicode problem.
For example, after error_text = str(e) there can be an unicode text, so this line will raise UnicodeDecodeError and will not exit runserver command:

self.stderr.write("Error: %s" % error_text)

Simple solution:

self.stderr.write("Error: %s" % error_text.decode('utf-8'))

Example of a problem: http://stackoverflow.com/questions/27248506/starting-with-django-server/27251575

Change History (7)

comment:1 Changed 6 years ago by Andriy Sokolovskiy

Description: modified (diff)

comment:2 Changed 6 years ago by Tim Graham

Has patch: set
Triage Stage: UnreviewedAccepted

comment:3 Changed 6 years ago by Berker Peksag

Triage Stage: AcceptedReady for checkin

comment:4 Changed 6 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In bba545345f46f09245799f7ae0a22177a84eba71:

Fixed #23946 -- Fixed runserver crash when socket error contains Unicode chars.

comment:5 Changed 6 years ago by Tim Graham <timograham@…>

In 2d0d6cadd41a132950e28fd08a99f72c085e0a42:

[1.7.x] Fixed #23946 -- Fixed runserver crash when socket error contains Unicode chars.

Backport of bba545345f46f09245799f7ae0a22177a84eba71 from master

comment:6 Changed 6 years ago by Tim Graham <timograham@…>

In 5c773447c3239a297b22929f0df15d2971d72e77:

Tweaked fix for refs #23946; thanks Claude.

comment:7 Changed 6 years ago by Tim Graham <timograham@…>

In 0a70d63b0b7cced774270586768ccb5ccebbb7ca:

[1.7.x] Tweaked fix for refs #23946; thanks Claude.

Backport of 5c773447c3239a297b22929f0df15d2971d72e77 from master

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