Bug report
Bug description:
UserString.rindex raises a TypeError when its sub argument is a UserString object. This behavior is inconsistent with UserString.rfind and most other string methods.
fromcollectionsimportUserStringus=UserString("hello world")
sub=UserString("world")
assertus.rfind(sub) ==us.rfind(sub.data)
assertus.rindex(sub) ==us.rindex(sub.data)Traceback (mostrecentcalllast):
File"/src/test.py", line7, in<module>assertus.rindex(sub) ==us.rindex(sub.data)
^^^^^^^^^^^^^^File"/py312/lib/python3.12/collections/__init__.py", line1553, inrindexreturnself.data.rindex(sub, start, end)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^TypeError: mustbestr, notUserString
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
UserString.rindexraises aTypeErrorwhen itssubargument is aUserStringobject. This behavior is inconsistent withUserString.rfindand most other string methods.CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
UserString.rindex(),UserString.index()accept UserString as sub argument. #140945