Martijn Pieters added the comment:
> Is 2.7 free from this bug?
No, 2.7 is affected too:
>>> class SubclassedStr(str):
... def __rmod__(self, other):
... return 'Success, self.__rmod__({!r}) was called'.format(other)
...
>>> 'lhs %% %r' % SubclassedStr('rhs')
"lhs % 'rhs'"
Expected output is "Success, self.__rmod__('lhs %% %r') was called"
On the plus side, unicode is not affected:
>>> class SubclassedUnicode(unicode):
... def __rmod__(self, other):
... return u'Success, self.__rmod__({!r}) was called'.format(other)
...
>>> u'lhs %% %r' % SubclassedUnicode(u'rhs')
u"Success, self.__rmod__(u'lhs %% %r') was called"
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28598>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com