#16261: Model.__repr__() should never return unicode
--------------------------------------+------------------------------
Reporter: lsaffre | Owner: nobody
Type: Bug | Status: closed
Milestone: | Component: Core (Other)
Version: 1.3 | Severity: Normal
Resolution: worksforme | 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 aaugustin):
* status: new => closed
* needs_better_patch: => 0
* component: Uncategorized => Core (Other)
* resolution: => worksforme
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug
Comment:
Since `smart_str` returns a bytestring version of its first argument, the
current implementation of `__repr__` always returns a bytestring.
So I don't understand why you suggest this change.
Also, it is backwards incompatible for people relying on a certain format
of `__repr__` in their tests.
----
__On the general topic of `__repr__` and unicode__
The Python docs say that `__repr__` should return a "string
representation". Your argument is that "string representation" means
"instance of `str`" and not "instance of `basestr`", but I'm not
convinced.
This bug (http://bugs.python.org/issue5876) says that `__repr__` can
return unicode, which should be automatically converted as needed.
Apparently, this feature was broken between 2.4 and 2.5.
Even if `__repr__` actually returned unicode, I'm not sure we would change
it.
--
Ticket URL: <https://code.djangoproject.com/ticket/16261#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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.