Changes between Version 1 and Version 2 of Ticket #25730, comment 3


Ignore:
Timestamp:
Nov 10, 2015, 10:20:15 PM (9 years ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #25730, comment 3

    v1 v2  
    33The default `__str__` implementation returns `u'%s object' % self.__class__.__name__` if `not hasattr(self, '__unicode__')`.
    44
     5It 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
    57This 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.
Back to Top