Skip to content

Fix compact divisor for explicit negative subpatterns - #1493

Open
manav4u wants to merge 1 commit into
python-babel:masterfrom
manav4u:fix-compact-negative-subpattern-divisor
Open

manav4u wants to merge 1 commit into
python-babel:masterfrom
manav4u:fix-compact-negative-subpattern-divisor

Conversation

@manav4u

@manav4u manav4u commented Nov 26, 2026

Copy link
Copy Markdown

Swahili compact patterns can include both signs, for example elfu 0;elfu -0. _get_compact_format() counts every zero in that string when computing the divisor, so 1000 becomes elfu 10 and 100000 becomes elfu 100000. The same error affects compact currencies.

Use the parsed pattern's minimum integer precision instead. That counts the positive numeric subpattern without counting the negative subpattern or literal zeros. Add 18 regression cases for both signs, three magnitudes, short/long decimals and compact EUR currency.

Validation: full suite on Python 3.10 and 3.14, Linux, CLDR 49: 8307 passed, 3 skipped, 2 xfailed on each. The 18 regressions fail before the fix. Ruff and diff checks pass. A separate 1164-case comparison across affected Swahili locales matched Node 22.23.5/ICU 78.3; Node uses CLDR 48.0.

This is a pre-existing divisor error, independent of the unscaled-rounding work in #1486. AI assistance was used for investigation, implementation and testing.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants