Skip to content

Conversation

@XChaitanyaX
Copy link
Contributor

@XChaitanyaX XChaitanyaX commented Nov 3, 2025

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

@XChaitanyaX XChaitanyaX 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

@PredictiveManish PredictiveManish 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
Contributor Author

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

Copy link
Member

@serhiy-storchaka serhiy-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
Contributor Author

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-storchaka serhiy-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-storchaka serhiy-storchaka merged commit e6174ee into python:main Nov 25, 2025
50 checks passed
@serhiy-storchaka serhiy-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 <141550576+XChaitanyaX@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Nov 25, 2025

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

@bedevere-app bedevere-app bot 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 <141550576+XChaitanyaX@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Nov 25, 2025

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

@bedevere-app bedevere-app bot 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 <141550576+XChaitanyaX@users.noreply.github.com>
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 <141550576+XChaitanyaX@users.noreply.github.com>
@XChaitanyaX XChaitanyaX deleted the pr_140911 branch November 25, 2025 14:32
Sign up for free to 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