Open
Description
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
in test_format.py
is failing.
I see two ways forward:
- Make RustPython/Parser/format aware of
libc::locale
. This would involve adding a dependency on libc. - In
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.