BUG: raise a proper exception when str.rsplit is passed a regex and clarify the docs#62035
BUG: raise a proper exception when str.rsplit is passed a regex and clarify the docs#62035hamdanal wants to merge 7 commits intopandas-dev:mainfrom
Conversation
| if pat is not None and not isinstance(pat, str): | ||
| msg = f"expected a string object, not {type(pat).__name__}" | ||
| raise TypeError(msg) |
There was a problem hiding this comment.
Can you put this in _str_rsplit for each implementation?
There was a problem hiding this comment.
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.
|
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. |
|
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
Thanks @mroeschke. There were no failing tests and I just merged main. Could you please reopen? Regarding the unresolved review comment above, could you explain why you want the exception to be raised for each implementation instead of in |
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.Noticed this while working on pandas-dev/pandas-stubs#1278.
rsplitdoesn'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.