Changes between Version 1 and Version 2 of Ticket #25730, comment 3
- Timestamp:
- Nov 10, 2015, 10:20:15 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #25730, comment 3
v1 v2 3 3 The default `__str__` implementation returns `u'%s object' % self.__class__.__name__` if `not hasattr(self, '__unicode__')`. 4 4 5 It wouldn't hurt to simply prefix the default format with a `b` but I don't think it's worth a backport. Most calls to `__str__` are made implicitly through `str()` which automatically tries to `encode('ascii')` when fed `unicode`. 6 5 7 This isn't really an issue because `self.__class__.__name__` can only contain ASCII characters on Python 2 and thus the returned string is always successfully coerced to a bytestring when required unless I'm missing something. 6 7 It wouldn't hurt to simply prefix the default format with a `b` but I don't think it's worth a backport. Most calls to `__str__` are made implicitly through `str()` which automatically tries to `encode('ascii')` when fed `unicode` which will never fail given the nature of `self.__class__.__name__` on Python 2.