python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.29k stars 432 forks source link

fix(numbers): correctly determine malformed decimals #1042

Closed olunusib closed 7 months ago

olunusib commented 7 months ago

Fixes #928

Problem:

The current code was primarily designed for numbers like 3,400.00, where the r-stripped value (3,400.) matches the expected proper (3,400) + . (3,400.) format. It doesn't work for numbers like 3,400.60 since 3,400.6 (the value after r-stripping) is incorrectly perceived as not equal to the expected format, which is the proper (3,400.6) + . (3,400.6.), thereby leading to its erroneous detection as improperly formatted.

Solution:

Added a more robust method for stripping trailing zeros, specifically targeting only those zeros that appear after the last non-zero digit following the decimal symbol.

codecov[bot] commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (aca7663) 91.43% compared to head (e89a6c9) 91.44%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1042 +/- ## ========================================== + Coverage 91.43% 91.44% +0.01% ========================================== Files 26 26 Lines 4436 4444 +8 ========================================== + Hits 4056 4064 +8 Misses 380 380 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.