Opened 10 years ago

Closed 10 years ago

Last modified 10 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: dev
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 by Andriy Sokolovskiy, 10 years ago

Description: modified (diff)

comment:2 by Tim Graham, 10 years ago

Has patch: set
Triage Stage: UnreviewedAccepted

comment:3 by Berker Peksag, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In bba545345f46f09245799f7ae0a22177a84eba71:

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

comment:5 by Tim Graham <timograham@…>, 10 years ago

In 2d0d6cadd41a132950e28fd08a99f72c085e0a42:

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

Backport of bba545345f46f09245799f7ae0a22177a84eba71 from master

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

In 5c773447c3239a297b22929f0df15d2971d72e77:

Tweaked fix for refs #23946; thanks Claude.

comment:7 by Tim Graham <timograham@…>, 10 years ago

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