You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
unicodedata.east_asian_width returns wrong result for unassigned Unicode code points #96172
I'd be happy to fix this, if people agree that it should be fixed. FWIW, PyPy has always returned 'N' in this situation. For assigned code points everything is fine.
Some unassigned codepoints should be 'N', others should be 'W', and there are some assigned codepoints that are also wrong, e.g. U+061D (Other_Punctuation) and a whole sequence starting at U+0870 (Other_Letter) should be 'N', amongst others.
I have a package "uniprop" on PyPI that you can use for crosschecking.
@mrabarnett interesting, did you report these issues? how are the tables in the uniprop are generated by this script, I assume?: https://bitbucket.org/mrabarnett/mrab-regex/src/hg/tools/build_regex_unicode.py
I didn't know that unicodedata had a problem until you reported it here.
I didn't use build_regex_unicode.py for uniprop, I used a related script, because the files generated by the former script don't contain all the stuff that uniprop needs. I really need to finish consolidating them so that I can use the one script for both.
Thanks for the info! yeah, you're right, basically unicodedata as of now seems to ignore all the "reserved" ranges from EastAsianWidth.txt, in addition to the wrong default, eg:
I think the U+061D and U+0870... problems you reported might be because those characters were added in 14.0.0, right? did you compare against CPython 3.10 by chance (which uses 13.0.0)?
Activity
mrabarnett commentedon Aug 22, 2022
You're both right and wrong.
Some unassigned codepoints should be 'N', others should be 'W', and there are some assigned codepoints that are also wrong, e.g. U+061D (Other_Punctuation) and a whole sequence starting at U+0870 (Other_Letter) should be 'N', amongst others.
I have a package "uniprop" on PyPI that you can use for crosschecking.
cfbolz commentedon Aug 22, 2022
@mrabarnett interesting, did you report these issues? how are the tables in the
unipropare generated by this script, I assume?:https://bitbucket.org/mrabarnett/mrab-regex/src/hg/tools/build_regex_unicode.pymrabarnett commentedon Aug 22, 2022
I didn't know that
unicodedatahad a problem until you reported it here.I didn't use
build_regex_unicode.pyforuniprop, I used a related script, because the files generated by the former script don't contain all the stuff thatunipropneeds. I really need to finish consolidating them so that I can use the one script for both.cfbolz commentedon Aug 22, 2022
Thanks for the info! yeah, you're right, basically
unicodedataas of now seems to ignore all the "reserved" ranges fromEastAsianWidth.txt, in addition to the wrong default, eg:I think the U+061D and U+0870... problems you reported might be because those characters were added in 14.0.0, right? did you compare against CPython 3.10 by chance (which uses 13.0.0)?
mrabarnett commentedon Aug 22, 2022
Yes, you're correct. Anyway, I count 830_672 incorrect values out of 1_114_112, a mere 75%. :-)
cfbolz commentedon Aug 22, 2022
heh :-). feel like sharing your comparison script?
mrabarnett commentedon Aug 22, 2022
OK, here it is, tidied up a little:
pythonGH-96172 unicodedata: fix wrong default for east_asian_width
GH-96172 fix unicodedata.east_asian_width being wrong on unassigned c…