Skip to content

Conversation

@XChaitanyaX
Copy link
Contributor

@XChaitanyaXXChaitanyaX commented Nov 3, 2025

Add isinstance check to both methods index(), rindex()

@XChaitanyaXXChaitanyaX changed the title gh-140911: Make sure that UserString.rindex(), UserString.index() accept UserString as sub argument.gh-140911: Ensure that UserString.rindex(), UserString.index() accept UserString as sub argument.Nov 3, 2025
Copy link

@PredictiveManishPredictiveManish left a 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
Copy link
ContributorAuthor

@serhiy-storchaka can you please review this...

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a 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.

@XChaitanyaX
Copy link
ContributorAuthor

self.checkequal( 2, 'rrarrrrrrrrra', 'find', 'a')

self.checkequal( 2, 'rrarrrrrrrrra', 'find', 'a', None, 6)

are the leading whitespaces just before 2 kept for readability??

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a 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.

@serhiy-storchakaserhiy-storchaka merged commit e6174ee into python:mainNov 25, 2025
50 checks passed
@serhiy-storchakaserhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Nov 25, 2025
@miss-islington-app
Copy link

Thanks @XChaitanyaX for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @XChaitanyaX for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 25, 2025
…() accept UserString as argument (pythonGH-140945) (cherry picked from commit e6174ee) Co-authored-by: Krishna Chaitanya <[email protected]>
@bedevere-app
Copy link

GH-141945 is a backport of this pull request to the 3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13 bugs and security fixes label Nov 25, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 25, 2025
…() accept UserString as argument (pythonGH-140945) (cherry picked from commit e6174ee) Co-authored-by: Krishna Chaitanya <[email protected]>
@bedevere-app
Copy link

GH-141946 is a backport of this pull request to the 3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14 bugs and security fixes label Nov 25, 2025
serhiy-storchaka pushed a commit that referenced this pull request Nov 25, 2025
…x() accept UserString as argument (GH-140945) (GH-141945) (cherry picked from commit e6174ee) Co-authored-by: Krishna Chaitanya <[email protected]>
serhiy-storchaka pushed a commit that referenced this pull request Nov 25, 2025
…x() accept UserString as argument (GH-140945) (GH-141946) (cherry picked from commit e6174ee) Co-authored-by: Krishna Chaitanya <[email protected]>
@XChaitanyaXXChaitanyaX deleted the pr_140911 branch November 25, 2025 14:32
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
ashm-dev pushed a commit to ashm-dev/cpython that referenced this pull request Dec 8, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@XChaitanyaX@serhiy-storchaka@PredictiveManish