#16261: Model.__repr__() should never return unicode
---------------------------+-------------------------------
Reporter: lsaffre | Owner: nobody
Type: Uncategorized | Status: new
Milestone: | Component: Uncategorized
Version: 1.3 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------+-------------------------------
Unlike stated in ticket #13831,
and according to
[http://stackoverflow.com/questions/3627793/best-output-type-and-coding-
practices-for-repr-functions this post on slashdot],
it seems that {{{__repr__()}}} should never return unicode in Python 2.
The current version does:
{{{
def __repr__(self):
try:
u = unicode(self)
except (UnicodeEncodeError, UnicodeDecodeError):
u = '[Bad Unicode data]'
return smart_str(u'<%s: %s>' % (self.__class__.__name__, u))
}}}
My suggestion would be to change this to:
{{{
def __repr__(self):
try:
u = unicode(self)
except (UnicodeEncodeError, UnicodeDecodeError):
u = '[Bad Unicode data]'
return '<%s: %r>' % (self.__class__.__name__, u)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/16261>
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.