Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: raise a proper exception when str.rsplit is passed a regex and clarify the docs #62035

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

Open
hamdanal wants to merge 1 commit into pandas-dev:main
base: main
Choose a base branch
Loading
from hamdanal:str.rsplit

Conversation

Copy link

@hamdanal hamdanal commented Aug 3, 2025

Noticed this while working on pandas-dev/pandas-stubs#1278. rsplit doesn't accept regular expressions but was silently accepting them and producing bad results. I added a check on the type of the input and updated the documentation.

Comment on lines +946 to +948
if pat is not None and not isinstance(pat, str):
msg = f"expected a string object, not {type(pat).__name__}"
raise TypeError(msg)
Copy link
Member

@mroeschke mroeschke Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this in _str_rsplit for each implementation?

Copy link
Author

@hamdanal hamdanal Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure no problem but this exact error is raised here for the other methods so I was following the same process. See for example find.

@mroeschke mroeschke added the Strings String extension data type and string data label Aug 4, 2025
Copy link
Contributor

github-actions bot commented Sep 4, 2025

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@mroeschke mroeschke mroeschke left review comments

Assignees
No one assigned
Labels
Stale Strings String extension data type and string data
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Series.str.rsplit not working with regex patterns (v 0.24.2 and 0.25.2)

AltStyle によって変換されたページ (->オリジナル) /