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: string format with 'n' failling with french locales
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: float.__format__('n') fails with _PyUnicode_CheckConsistency assertion error for locales with non-ascii thousands separator
View: 33954
Assigned To: Nosy List: David Vasseur, eric.smith, licht-t
Priority: normal Keywords: patch

Created on 2018-05-12 11:30 by David Vasseur, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 6861 closed licht-t, 2018-05-15 15:10
Messages (4)
msg316426 - (view) Author: David Vasseur (David Vasseur) Date: 2018-05-12 11:30
Python 3.6.5 (default, Apr 14 2018, 13:17:30) 
[GCC 7.3.1 20180406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('{:n}'.format(int(12)))
12 <-- ok --

>>> import locale
>>> locale.setlocale(locale.LC_ALL, '')
'fr_FR.UTF-8'
>>> print('{:n}'.format(int(12)))
(empty) <-- error --
'{:n}'.format(int(12))
'Àæ' <-- error --

please note that with >999 numbers, it's working fine:
>>> print('{:n}'.format(int(1000)))
1 000 <-- ok --
msg316442 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2018-05-13 01:56
After locale.setlocale(locale.LC_ALL, ''), what does local.localeconv() return?
msg316456 - (view) Author: David Vasseur (David Vasseur) Date: 2018-05-13 09:19
>>> locale.localeconv()
{'int_curr_symbol': 'EUR ', 'currency_symbol': '€', 'mon_decimal_point': ',', 'mon_thousands_sep': '\u202f', 'mon_grouping': [3, 0], 'positive_sign': '', 'negative_sign': '-', 'int_frac_digits': 2, 'frac_digits': 2, 'p_cs_precedes': 0, 'p_sep_by_space': 1, 'n_cs_precedes': 0, 'n_sep_by_space': 1, 'p_sign_posn': 1, 'n_sign_posn': 1, 'decimal_point': ',', 'thousands_sep': '\u202f', 'grouping': [3, 0]}
msg316548 - (view) Author: Licht Takeuchi (licht-t) * Date: 2018-05-14 18:46
I am working on this and have found why this is happening.
I'll make PR in few days.
History
Date User Action Args
2022-04-11 14:59:00adminsetgithub: 77652
2020-01-12 02:29:51cheryl.sabellasetstatus: open -> closed
superseder: float.__format__('n') fails with _PyUnicode_CheckConsistency assertion error for locales with non-ascii thousands separator
resolution: duplicate
stage: patch review -> resolved
2018-05-18 17:23:26terry.reedysetversions: + Python 3.7, Python 3.8
2018-05-15 15:10:09licht-tsetkeywords: + patch
stage: patch review
pull_requests: + pull_request6535
2018-05-14 18:46:42licht-tsetnosy: + licht-t
messages: + msg316548
2018-05-13 09:19:40David Vasseursetmessages: + msg316456
2018-05-13 01:56:12eric.smithsetnosy: + eric.smith
messages: + msg316442
2018-05-12 11:30:06David Vasseurcreate