Tryton - Issues



Title Formatting Decimal with digits >=16
Priority bug Status resolved
Superseder Nosy List ced, reviewbot, roundup-bot
Type behavior Components tryton
Assigned To ced Keywords backport, review
Reviews 282011002
View: 282011002

Created on 2019-08-14.16:03:18 by ced, last changed by roundup-bot.

New changeset faacf8578e9a by Cédric Krier in branch 'default':
Use locale.localize() and new format to format Decimal
New changeset bfb8b9a6d64d by Cédric Krier in branch 'default':
Use locale.localize() and new format to format Decimal
review282011002 updated at
msg54835 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2020-01-13.23:43:21
I'm quite tired to wait for inclusion in Python.
I think we can take the risk to apply the review before inclusion. At worst, it is never applied so there will be no collision. Otherwise it is applied with a different implementation (not likely) but then we could issue a bugfix patch if needed.
review282011002 updated at
msg51288 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-08-14.16:07:36
Here is review282011002 but I prefer to wait until the method is included in Python.
msg51287 (view) Author: [hidden] (ced) (Tryton committer) (Tryton translator) Date: 2019-08-14.16:03:18
We use locale.format() to format the Decimal (and float) with the formatter '%.*f'. The problem is that internally Python convert the Decimal into float and than format it. So we have a loose of precision which can have bad result. E.g:

>>> locale.format('%.*f', (16, Decimal('1.15')))

This was reported on
And I made a proposal to add a new method locale.localize() in the stdlib.

I propose to monkey patch locale to include this method and to use it.
Date User Action Args
2020-01-20 11:26:59roundup-botsetmessages: + msg54923
2020-01-20 11:26:52roundup-botsetstatus: testing -> resolved
nosy: + roundup-bot
messages: + msg54922
2020-01-14 00:06:50reviewbotsetnosy: + reviewbot
messages: + msg54851
2020-01-13 23:43:22cedsetmessages: + msg54835
2019-08-14 16:13:42cedsetnosy: - reviewbot
keyword: + backport
2019-08-14 16:13:30reviewbotsetnosy: + reviewbot
messages: + msg51289
2019-08-14 16:07:36cedsetstatus: in-progress -> testing
reviews: 282011002
messages: + msg51288
keyword: + review
2019-08-14 16:03:18cedcreate

Showing 10 items. Show all history (warning: this could be VERY long)