#28067: Encoding error when __str__ returns non-ASCII
-------------------------------------+-------------------------------------
Reporter: Christophe Pettus | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 1.11
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):
* status: new => closed
* resolution: => invalid
Comment:
When using `@python_2_unicode_compatible`, `__str__()` must return "text"
(unicode). Using `str()` returns bytes on Python 2. Use
`six.text_type(self.a)` instead.
On Python 3, `python_2_unicode_compatible` does nothing. On Python 2, it
aliases the `__str__` method to `__unicode__` and creates a new `__str__`
method that returns the result of `__unicode__()` encoded with UTF-8.
--
Ticket URL: <https://code.djangoproject.com/ticket/28067#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/061.e2793510e65a5f5a34c842e54fef0a16%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.