-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-129569: The function unicodedata.normalize() always returns built-in str #129570
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
Merged
vstinner
merged 16 commits into
python:main
from
Hizuru3:unicodedata-normalize-always-returns-exact-str
Feb 21, 2025
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
cba7f34
Update unicodedata.c
Hizuru3 b0f3192
Merge branch 'python:main' into unicodedata-normalize-always-returns-…
Hizuru3 0856f1b
📜🤖 Added by blurb_it.
blurb-it[bot] 59c6b8c
Merge branch 'python:main' into unicodedata-normalize-always-returns-…
Hizuru3 0028ffb
Add NormalizationTest.test_issue129569() to test_unicodedata.py
Hizuru3 40a9cf4
Merge branch 'python:main' into unicodedata-normalize-always-returns-…
Hizuru3 fa11610
Rename and refactor test method for the str subclass in test_unicoded…
Hizuru3 2150ffb
Merge branch 'python:main' into unicodedata-normalize-always-returns-…
Hizuru3 1dd3b75
Update NormalizationTest.test_normalize_func_shall_return_exact_str()…
Hizuru3 30af45e
Merge branch 'python:main' into unicodedata-normalize-always-returns-…
Hizuru3 22f7973
Update Lib/test/test_unicodedata.py
Hizuru3 55ad3df
Update Lib/test/test_unicodedata.py
Hizuru3 dd41cf9
Update NormalizationTest.test_normalize_return_type() in test_unicode…
Hizuru3 8c27430
Update issue description
Hizuru3 9e47f9e
Merge branch 'python:main' into unicodedata-normalize-always-returns-…
Hizuru3 0aef15e
Merge branch 'main' into unicodedata-normalize-always-returns-exact-str
Hizuru3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
1 change: 1 addition & 0 deletions
1
Misc/NEWS.d/next/Library/2025-02-02-16-30-27.gh-issue-129569.i0kPOG.rst
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix :func:`unicodedata.normalize` to always return a built-in :class:`str` object when given an input of a :class:`str` subclass, regardless of whether the string is already normalized. |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use itertools.product to also iterate over the possible strings and the possible classes if you want and add input_str=..., as well as input_type=... in the sub test parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just use two loops.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I integrated the input strings but I don't see an obvious advantage to iterate over classes since the only two patterns, one of which is the built-in str, are possible here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, my intent was to reduce the overall indentation using
itertools.product
, but if we're using nested loops it's fine to keep it as is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
itertools.product
is cool but it really shines with 3+ nested constructs IMHO.