Skip to content

Return the single-level mapping from unicodedata.decomposition - #1344

Open
taxor03 wants to merge 1 commit into
oracle:masterfrom
taxor03:GH-unicodedata-raw-decomposition
Open

taxor03 wants to merge 1 commit into
oracle:masterfrom
taxor03:GH-unicodedata-raw-decomposition

Conversation

@taxor03

@taxor03 taxor03 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #1340

unicodedata.decomposition() used ICU's Normalizer2.getDecomposition(), which applies the mapping recursively, so characters such as Ấ, DŽ or U+212B ANGSTROM SIGN got the fully expanded sequence. CPython returns the decomposition field from UnicodeData.txt as it is, which is what getRawDecomposition() gives. The one exception is Hangul syllables: CPython builds their full L V T jamo sequence (unicodedata.c#L430-L447), while the raw mapping of an LVT syllable is LV + T, so they keep using getDecomposition().

AS-IS

>>> [unicodedata.decomposition(c) for c in "ẤDŽÅ"]
['0041 0302 0301', '<compat> 0044 005A 030C', '0041 030A']

TO-BE

['00C2 0301', '<compat> 0044 017D', '00C5']

(matching CPython)

Changes

  • In UnicodeDataModuleBuiltins.DecompositionNode, use getRawDecomposition(), and getDecomposition() only for Hangul syllables (U+AC00 to U+D7A3).
  • Add test_decomposition to tests/test_unicodedata.py with multi-level mappings (DŽ, ẛ, Ǖ), a fraction, a character without a mapping, and an LV and an LVT syllable. It passes on CPython 3.13 and 3.14.

Testing

mx python-jvm on darwin-aarch64, then mx graalpytest test_unicodedata (9 passed) and --tagged test_unicodedata (41 passed). Over all code points, the output now equals CPython 3.13.18 for every character that CPython 3.13 assigns a mapping (514 differed before); the only remaining differences are characters added after Unicode 15.1. Without the change, the new test fails on DŽ. mx checkstyle --primary and mx eclipseformat --primary report nothing.

Signed-off-by: Sungmin Park <ryan040@korea.ac.kr>
@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Nov 24, 2026

This branch has not been deployed

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

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

1 participant