#25730: base.Model __str__ sometimes returns unicode on Python 2
-------------------------------------+-------------------------------------
Reporter: keturn | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by keturn):
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Old description:
> base.py contains `from __future__ import unicode_literals`
>
> so the thing that `Model.__str__` returns is a unicode object in the case
> where `hasattr(self, '__unicode__')` is False.
>
> There's a `force_text().encode()` on the other case; probably both cases
> should use `smart_str`.
>
> Discovered under Django 1.7 but this looks to still be the case in the
> master branch.
New description:
base.py contains `from __future__ import unicode_literals`
so the "" that `Model.__str__` returns is a unicode object in the case
where `hasattr(self, '__unicode__')` is False.
There's a `force_text().encode()` on the other case; probably both cases
should use `smart_str`.
Discovered under Django 1.7 but this looks to still be the case in the
master branch.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/25730#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/064.aee57b26da65f7f0b719dcef739b3c03%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.