bpo-18236: Adjust str.isspace to use Unicode's White_Space property.#16254
Open
gnprice wants to merge 1 commit intopython:mainfrom
Open
bpo-18236: Adjust str.isspace to use Unicode's White_Space property.#16254gnprice wants to merge 1 commit intopython:mainfrom
gnprice wants to merge 1 commit intopython:mainfrom
Conversation
When Unicode support was first added to Python, there was no Unicode property identifying whitespace, so we approximated it by putting together a couple of other properties. Now there is a White_Space property, so let's use it. Happily, the difference from our original approximation is only in the four rare control characters 001C..001F. As a bonus, `isspace` now joins all similar methods in giving exactly matching results for ASCII characters represented as `str` or as `bytes`. Add a test for that nice property.
Numerlor
reviewed
May 3, 2022
Contributor
Numerlor
left a comment
There was a problem hiding this comment.
Ran into an issue with this when I noticed int's stripping is different to str's, so it's nice to see that there's already a PR for a fix.
The introduced changes seem good to my eye that's not entirely familiar with the codebase, apart from the outdated version notices.
I've also noticed that the added docstrings to test_unicode are using single quote marks while others are using double quotes so changing that to be consistent would be nice
Comment on lines
+640
to
+642
| ((bidirectional in ('WS', 'B', 'S') | ||
| or category == 'Zs') | ||
| and codepoint not in range(0x1c, 0x20))) |
Contributor
There was a problem hiding this comment.
Is this guaranteed to hold in future unicode versions? i.e. should it be tested on the string method if it's only testing the unicode database parsing and generation?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When Unicode support was first added to Python, there was no Unicode
property identifying whitespace, so we approximated it by putting
together a couple of other properties.
Now there is a White_Space property, so let's use it.
Happily, the difference from our original approximation is only in the
four rare control characters 001C..001F.
As a bonus,
isspacenow joins all similar methods in giving exactlymatching results for ASCII characters represented as
stror asbytes. Add a test for that nice property.https://bugs.python.org/issue18236