Skip to content

Commit

Permalink
Fix:Unexpected behaviour: parse_numbers() doesn't handle space as a g…
Browse files Browse the repository at this point in the history
…rouping symbol, however, parse_decimal() does python-babel#1061
  • Loading branch information
sebas-inf committed Jan 31, 2024
1 parent f225845 commit 88386e9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions babel/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,15 +1029,14 @@ def parse_number(
:raise `UnsupportedNumberingSystemError`: if the numbering system is not supported by the locale.
"""
try:
# Get the group and decimal symbols from the locale
# Get the group symbol from the locale
group_symbol = get_group_symbol(locale, numbering_system=numbering_system)
decimal_symbol = Locale.parse(locale).number_symbols.get('decimal', '.')

# Replace non-breakable spaces with the group symbol and remove other spaces
cleaned_string = string.replace('\xa0', group_symbol).replace(' ', '')

# Remove group symbols and replace the decimal symbol with a dot
cleaned_string = cleaned_string.replace(group_symbol, '').replace(decimal_symbol, '.')
cleaned_string = cleaned_string.replace(group_symbol, '').replace('.', '')

return int(cleaned_string)
except ValueError as ve:
Expand Down

0 comments on commit 88386e9

Please sign in to comment.