gh-73123: Add a keepempty argument to string, bytes and bytearray split methods#26222
gh-73123: Add a keepempty argument to string, bytes and bytearray split methods#26222MarkCBell wants to merge 28 commits intopython:mainfrom
Conversation
tiran
left a comment
There was a problem hiding this comment.
PyUncode_Split() and PyUnicode_RSplit() are in the stable ABI and API. You cannot modify the function arguments. Instead you have to create additional functions.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
Thank you for letting me know about the API / ABI. I have changed this PR so that it leaves I have decided that the C API interfaces add little extra value and so have removed them. If it is decided later that these are useful then they can be re-added by reverting commit f95b254. Now that I have made the requested changes; please review again. |
|
Thanks for making the requested changes! @tiran: please review the changes made to this pull request. |
|
Could a maintainer approve running the last two jobs of the CI workflow for me please. |
|
I've left a comment in the issue tracker, I think there may be a potential problem with the API. |
|
This PR is stale because it has been open for 30 days with no activity. |


This PR adds an optional
keepemptyargument to string.split (and similarly for bytes.split, bytearray.split and UserString.split). As described in issue bpo-28937:keepemptyis true then empty strings are never stripped out of the result array.keepemptyis false then empty strings are always stripped out of the result array.keepemptyisNone(the default) then the current behaviour is followed in which empty strings are stripped out of the result array if and only if the separator string isNone.To do this it uses a new splitting algorithm which has been designed to be compatible with the existing
maxsplitargument. This is roughly:A number of tests have been added to check the correct behaviour.
https://bugs.python.org/issue28937