Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-140911: Ensure that UserString.rindex(), UserString.index() accept UserString as sub argument.#140945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
XChaitanyaX commented Nov 3, 2025 • edited by bedevere-app bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-app bot
Uh oh!
There was an error while loading. Please reload this page.
UserString.rindex(), UserString.index() accept UserString as sub argument.UserString.rindex(), UserString.index() accept UserString as sub argument.
PredictiveManish left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Closes: in description! so that it directly links to main issue (like below)
Add isinstance check to both methods index(), rindex()
Closes: #140911
XChaitanyaX commented Nov 21, 2025
@serhiy-storchaka can you please review this... |
serhiy-storchaka left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add tests?
Look at test_find, test_rfind and test_count methods in Lib/test/string_tests.py and add similar double loops in test_index and test_rindex.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
XChaitanyaX commented Nov 25, 2025
cpython/Lib/test/string_tests.py Line 173 in da1d468
cpython/Lib/test/string_tests.py Line 177 in da1d468
are the leading whitespaces just before |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
serhiy-storchaka left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
Thank you for your contribution, @XChaitanyaX.
e6174ee into python:mainUh oh!
There was an error while loading. Please reload this page.
Thanks @XChaitanyaX for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Thanks @XChaitanyaX for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…() accept UserString as argument (pythonGH-140945) (cherry picked from commit e6174ee) Co-authored-by: Krishna Chaitanya <[email protected]>
GH-141945 is a backport of this pull request to the 3.13 branch. |
…() accept UserString as argument (pythonGH-140945) (cherry picked from commit e6174ee) Co-authored-by: Krishna Chaitanya <[email protected]>
GH-141946 is a backport of this pull request to the 3.14 branch. |
…x() accept UserString as argument (GH-140945) (GH-141945) (cherry picked from commit e6174ee) Co-authored-by: Krishna Chaitanya <[email protected]>
…x() accept UserString as argument (GH-140945) (GH-141946) (cherry picked from commit e6174ee) Co-authored-by: Krishna Chaitanya <[email protected]>
…() accept UserString as argument (pythonGH-140945)
…() accept UserString as argument (pythonGH-140945)
Add
isinstancecheck to both methodsindex(),rindex()collections.UserString.rindex()fails to acceptUserStringassubargument #140911