Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixeseasystdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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, notUserStringCPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
- gh-140911: Ensure that
UserString.rindex(),UserString.index()accept UserString as sub argument. #140945 - [3.13] gh-140911: Ensure that UserString.index() and UserString.rindex() accept UserString as argument (GH-140945) #141945
- [3.14] gh-140911: Ensure that UserString.index() and UserString.rindex() accept UserString as argument (GH-140945) #141946
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixeseasystdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error