format()
does not support locales for 'n' presentation type
#5181
Labels
C-compat
A discrepancy between RustPython and CPython
Feature
There are a number of options available for formatting integers using the
format()
API. The default is'd'
. There is a closely related alternative formatting'n'
which works the same, but uses the locale settings to insert the correct separators. For example,format(123456789, 'n') == '123,456,789'
(I am in the US, so my locale specifies,
instead of.
).The current implementation does not include the separator, and therefore
test_locale
intest_format.py
is failing.I see two ways forward:
libc::locale
. This would involve adding a dependency on libc.int.rs
, get the locale info and pass it torustpython_parse::FormatSpec
. This would involve adding an alternative constructor to the RustPython/Parser/formatFormatSpec
that also accepts locale info.Python Documentation or reference to CPython source code
https://docs.python.org/3/library/string.html#formatspec, specifically the 'n' presentation type.
The text was updated successfully, but these errors were encountered: