Opened 9 years ago
Last modified 8 years ago
#26731 closed Bug
UnicodeDecodeError when writing unicode to stdout of management command — at Version 1
Reported by: | Darren Hobbs | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.8 |
Severity: | Normal | Keywords: | py2 |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
In a management command in Python 2.7, if you include unicode characters when writing to stdout (with self.stdout.write) you will get a UnicodeDecodeError
# coding=utf-8 from __future__ import absolute_import, unicode_literals import sys import pytest from django.core.management.base import OutputWrapper from django.utils.encoding import smart_bytes def test_bad_unicode_names(): bad_name = smart_bytes(u'£') ow = OutputWrapper(sys.stdout) with pytest.raises(UnicodeDecodeError): ow.write(bad_name)
Note:
See TracTickets
for help on using tickets.