Fix locale-aware SI value parsing - #3571
Conversation
|
Looks good. I originally introduced the locale-aware SI-value parsing, so I checked your PR. The siParse bug seems to have been an oversight, while the other bug was introduced in #3546 when "\w" was changed to "\S" to allow parsing of "°". This change allows that, and also fixes the bug introduced by that change. |
|
This is one of those cases where we will want a test that has many many parametrized inputs, with regular expressions this complicated (especially without the use of |
|
Thanks, I've expanded the coverage into a 26-case parameterized matrix. It now exercises period and comma locales across signed values, leading and trailing decimals, exponents, SI prefixes, Unicode units, and rejection of mixed or mismatched separators. The focused siParse/siEval run passes all 65 selected tests. |
Summary
Root cause
The comma-aware regex returned the localized numeric token unchanged, so
float()could not convert it. Separately, both locale regexes allowed any non-whitespace suffix start, which let a mismatched decimal separator and the remaining digits be treated as a suffix. That silently truncated the numeric value and could discard the intended SI prefix.Validation
pytest tests/test_functions.py tests/widgets/test_spinbox.py -q(228 passed, 2 skipped)git diff --checkFixes #3568.
Fixes #3569.