Skip to content

GH-96172 fix unicodedata.east_asian_width being wrong on unassigned code points - #96207

Merged
isidentical merged 4 commits into
python:mainfrom
cfbolz:gh-96172-unicodedata-east-asian-width-unassigned-bug
Aug 26, 2022
Merged

GH-96172 fix unicodedata.east_asian_width being wrong on unassigned code points#96207
isidentical merged 4 commits into
python:mainfrom
cfbolz:gh-96172-unicodedata-east-asian-width-unassigned-bug

Conversation

@cfbolz

@cfbolz cfbolz commented Aug 23, 2022

Copy link
Copy Markdown
Contributor

unicodedata.east_asian_width returned the wrong value in two situations:

  • by default for unassigned code points (should return 'N', did return 'F')
  • for reserved but unassigned code points (should return 'W', did return 'F')

This is fixed by changing the default return value through reordering the list EASTASIANWIDTH_NAMES and by adding records for unassigned but reserved entries.

cfbolz added 2 commits August 23, 2022 13:26
also return the correct width for unassigned but reserved characters
according to EastAsianWidth.txt
- this guards against accidentally introducing changes in the future
- if east_asian_width had been part of the checksum from the beginning,
  the bug would have been found much earlier by PyPy
@isidentical
isidentical self-requested a review August 23, 2022 13:35
Comment thread Tools/unicode/makeunicodedata.py
Comment thread Lib/test/test_unicodedata.py
@isidentical

Copy link
Copy Markdown
Member

@cfbolz do you know whether we handle the first case mentioned in "6.1 Unassigned and Private-Use Characters" (Wide for CJK):

Unassigned code points in ranges intended for CJK ideographs are classified as Wide. Those ranges are:

the CJK Unified Ideographs block, 4E00..9FFF
the CJK Unified Ideographs Extension A block, 3400..4DBF
the CJK Compatibility Ideographs block, F900..FAFF
the Supplementary Ideographic Plane, 20000..2FFFF
the Tertiary Ideographic Plane, 30000..3FFFF

All other unassigned code points are by default classified as Neutral.

@cfbolz

cfbolz commented Aug 24, 2022

Copy link
Copy Markdown
Contributor Author

@isidentical oops, I definitely had an explicit test, seems that got lost somehow. will retrieve it tomorrow. and yes, it definitely had characters from the CJK ranges that you list

@cfbolz

cfbolz commented Aug 24, 2022

Copy link
Copy Markdown
Contributor Author

it's in my first commit, but then in the third one I removed it again for some reason :-/. 5688e6a#diff-c31ff7b8fca97de6b4fdaca3e14da27ab3cac411653e9c510a5378b189f909eaR223

fixing tomorrow.

@isidentical

Copy link
Copy Markdown
Member

Amazing, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants