gh-140911: Ensure that UserString.rindex(), UserString.index() accept UserString as sub argument.#140945
Conversation
UserString.rindex(), UserString.index() accept UserString as sub argument.UserString.rindex(), UserString.index() accept UserString as sub argument.
There was a problem hiding this comment.
Add Closes: in description! so that it directly links to main issue (like below)
Add isinstance check to both methods index(), rindex()
Closes: #140911
|
@serhiy-storchaka can you please review this... |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
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.
|
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 |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
LGTM. 👍
Thank you for your contribution, @XChaitanyaX.
|
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 <141550576+XChaitanyaX@users.noreply.github.com>
|
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 <141550576+XChaitanyaX@users.noreply.github.com>
|
GH-141946 is a backport of this pull request to the 3.14 branch. |
…() 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