Skip to content
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

gh-101372: Fix unicodedata.is_normalized to properly handle the UCD 3… #101388

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

corona10
Copy link
Member

@corona10 corona10 commented Jan 28, 2023

@corona10
Copy link
Member Author

@serhiy-storchaka

All ranges of characters are candidates for testing.
So I decide to choose a sampling approach rather than choose specific cases.

Test script

import unicodedata

with open('foo.out', 'w') as f:
    for x in range(0x110000):
        for form in ('NFC', 'NFD', 'NFKC', 'NFKD'):
            norm = unicodedata.ucd_3_2_0.normalize(form, chr(x))
            if not unicodedata.ucd_3_2_0.is_normalized(form, norm):
                f.write(f'{str(x)},{form}\n')

AS-IS

(.oss) ➜  cpython git:(main) ✗ ./python.exe gh-101372.py
(.oss) ➜  cpython git:(main) ✗ wc -l foo.out
 4456448 foo.out

TO-BE


(.oss) ➜  cpython git:(gh-101372) ✗ ./python.exe gh-101372.py
(.oss) ➜  cpython git:(gh-101372) ✗ wc -l foo.out
       0 foo.out

@corona10 corona10 requested a review from serhiy-storchaka Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants