This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: locale.currency() uses different formatting than system locale for negative values
Type: behavior Stage: resolved
Components: Library (Lib), Windows Versions: Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: bram.marien, eric.smith
Priority: normal Keywords:

Created on 2010-10-13 10:36 by bram.marien, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
locale_currency_negative.JPG bram.marien, 2010-10-13 10:36
Messages (4)
msg118509 - (view) Author: Bram Mariën (bram.marien) Date: 2010-10-13 10:36
On Windows Vista and Windows 7 (XP and Ubuntu seem ok):

If the system locale is used (using locale.setlocale(LC_ALL, '') and the system locale is set to dutch belgium: 
If the regional options are set to format negative monetary items as "<EURO sign> -<value>", than locale.currency(value) will format it as "<EURO sign)value-".

Other formatting options works ok: e.g. if the regional settings display negative monetary items as "(value)", than "locale.currency(value)" will also display "{value)".

Reproducable on Python 2.6.x, 2.7.x and 3.1.2 on Windows Vista (32 bit)
msg118512 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-10-13 11:21
I don't have a copy of Vista or 7 handy to check with. Could you tell me what locale.localeconv() returns on a non-working system and on a working system (preferably Windows XP)?
msg118513 - (view) Author: Bram Mariën (bram.marien) Date: 2010-10-13 11:31
*  On Windows Vista (non working system): 

>>> locale.localeconv()
{'mon_decimal_point': ',', 'int_frac_digits': 2, 'p_sep_by_space': 1, 'frac_digits': 2, 'thousands_sep': '.', 'n_sign_posn': 4, 'decimal_point': ',', 'int_curr_symbol': 'EUR', 'n_cs_precedes': 1, 'p_sign_posn': 4, 'mon_thousands_sep': '.', 'negative_sign': '-', 'currency_symbol': '\x80', 'n_sep_by_space': 1, 'mon_grouping': [3, 0], 'p_cs_precedes': 1, 'positive_sign': '', 'grouping': [3, 0]}


* On Windows XP (Working system):
{'mon_decimal_point': ',', 'int_frac_digits': 2, 'p_sep_by_space': 1, 'frac_digits': 2, 'thousands_sep': '.', 'n_sign_posn': 1, 'decimal_point': ',', 'int_curr_symbol': 'EUR', 'n_cs_precedes': 0, 'p_sign_posn': 1, 'mon_thousands_sep': '.', 'negative_sign': '-', 'currency_symbol': '\x80', 'n_sep_by_space': 1, 'mon_grouping': [3, 0], 'p_cs_precedes': 0, 'positive_sign': '', 'grouping': [3, 0]}

The locale is set to 'Dutch_Belgium.1252'
msg118514 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-10-13 11:43
So it looks like locale.currency() is doing the right thing, given the values returned by locale.localeconv().

These values are copied from C's localeconv(), so the problem must be there. I don't see how we can do anything about it on the Python side, unfortunately.
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54292
2010-10-13 18:14:35eric.smithsetstatus: open -> closed
resolution: not a bug
stage: resolved
2010-10-13 11:43:33eric.smithsetmessages: + msg118514
2010-10-13 11:31:23bram.mariensetmessages: + msg118513
2010-10-13 11:22:18eric.smithsetcomponents: + Library (Lib)
2010-10-13 11:21:29eric.smithsetnosy: + eric.smith
messages: + msg118512
2010-10-13 10:36:25bram.mariencreate