Repository navigation
Normalize negative inputs in generated JavaScript plural rules - #1414
Merged
akx merged 2 commits intoNov 2, 2026
Merged
Conversation
Use absolute values before evaluating generated plural rules, matching Python and the Unicode plural operand definition. Cover source output and JavaScript execution for negative and positive inputs. Fixes python-babel#1413
akx
requested changes
Nov 2, 2026
akx
left a comment
Member
There was a problem hiding this comment.
The fix itself is fine. Just get rid of the unnecessary tests, please.
akx
approved these changes
Nov 2, 2026
akx
enabled auto-merge (squash)
November 2, 2026 10:26
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1414 +/- ##
==========================================
+ Coverage 93.51% 93.56% +0.05%
==========================================
Files 27 27
Lines 4932 4943 +11
==========================================
+ Hits 4612 4625 +13
+ Misses 320 318 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Normalize
nwithMath.absonce before evaluating generated JavaScript plural rules. This matches Python'sextract_operandsand the Unicode definition of plural operands as absolute values.For
{'one': 'n is 1', 'few': 'n in 2..4'}, Python selectsonefor-1andfewfor-2, while the current generated JavaScript selectsotherfor both.Update the generated-source expectations and add always-on normalization checks for empty, direct, integer, modulo and range rules. Four execution tests compare the generated function with Python for negative integers/fractions, zero and positive controls. They use Node.js when available and skip only those execution tests otherwise, without adding a required dependency. All four execution regressions fail on unchanged master.
Validation against
9a3ef47, Linux, imported CLDR 48.2:git diff --checkpass.Test runs used process-local
TZ=UTC: two unrelated host-timezone assertions fail with Asia/Calcutta on both unchanged master and this branch. No tests were deselected. The existing pytest parametrization warning remains. Windows/macOS were not run locally; upstream CI is still pending.Fixes #1413