New submission from James Emerton <ja...@emerton.info>:

We use locale.format('%.2f', x, True) to convert Decimal values to strings for 
display. Unfortunately, the locale module is using %-formatting to generate the 
initial string before applying locale specific formatting. As a result, any 
value which cannot be accurately represented as a float will produce incorrect 
results.

I've built some formatting that uses new-style string formatting (and some 
internal locale functions) which corrects the problem.

Unfortunately, making this change in the locale module would require converting 
the input format string to the new syntax, so '%.2f' would become '{:.2f}'.

See also #33731

----------
components: Library (Lib)
messages: 322885
nosy: jemerton
priority: normal
severity: normal
status: open
title: locale.format() and locale.format_string() cast Decimals to float
versions: Python 3.6, Python 3.7, Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34311>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to