Skip to content

parse_decimal is not works correctly when space symbol as grouping #637

Description

@llybin
from babel.numbers import format_decimal

format_decimal(12345.123, locale='ru')

'12\xa0345,123'
from babel.numbers import parse_decimal

parse_decimal('12 345,123', locale='ru')

babel/numbers.py", line 605, in parse_decimal
    .replace(get_decimal_symbol(locale), '.'))
decimal.InvalidOperation: [<class 'decimal.ConversionSyntax'>]
babel.numbers.NumberFormatError

There is a problem because ' '.replace('\xa0', '.') is not replace space to dot.

Activity

  1. added a commit that references this issue on May 27, 2019
    ec33844
  2. self-assigned this
    on May 27, 2019
  3. akx commented on May 27, 2019

    @akx
    Member

    This is technically by design, but it does make sense to allow a plain space in U+00A0's stead when it is the group separator.

  4. added a commit that references this issue on May 27, 2019
    4b6cd34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions