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.

Author zezollo
Recipients zezollo
Date 2018-06-21.16:00:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1529596837.65.0.56676864532.issue33934@psf.upfronthosting.co.za>
In-reply-to
Content
Expected behaviour:

When unset, the locale in use is `C` (as stated in python documentation) and `locale.getlocale()` returns  `(None, None)` on Linux with python2.7 or on Windows with python2.7 and python 3.6 (at least):


$ python2
Python 2.7.15 (default, May  1 2018, 20:16:04) 
[GCC 7.3.1 20180406] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale()
(None, None)
>>> 


Issue:

But when using python3.4+ on Linux, instead of `(None, None)`, `locale.getlocale()` returns the same value as `locale.getdefaultlocale()`:


$ python
Python 3.6.3 (default, Oct 24 2017, 14:48:20) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale()
('fr_FR', 'UTF-8')
>>> locale.localeconv()
{'int_curr_symbol': '', 'currency_symbol': '', 'mon_decimal_point': '', 'mon_thousands_sep': '', 'mon_grouping': [], 'positive_sign': '', 'negative_sign': '', 'int_frac_digits': 127, 'frac_digits': 127, 'p_cs_precedes': 127, 'p_sep_by_space': 127, 'n_cs_precedes': 127, 'n_sep_by_space': 127, 'p_sign_posn': 127, 'n_sign_posn': 127, 'decimal_point': '.', 'thousands_sep': '', 'grouping': []}
>>> locale.str(2.5)
'2.5'


Though the locale actually in use is still `C` (as shown above by the output of `locale.localeconv()` and confirmed by the result of `locale.str(2.5)`, which shows a dot as decimal point and not a comma (as expected with `fr_FR.UTF-8`)).

I could observe this confusing behaviour on Linux with python3.4, 3.5, 3.6 and 3.7 (rc1). (Also on FreeBSD with python3.6.1).

A problematic consequence of this behaviour is that it becomes impossible to detect whether the locale has already been set by the user, or not.

I could not find any other similar issue and hope this is not a duplicate.
History
Date User Action Args
2018-06-21 16:00:37zezollosetrecipients: + zezollo
2018-06-21 16:00:37zezollosetmessageid: <1529596837.65.0.56676864532.issue33934@psf.upfronthosting.co.za>
2018-06-21 16:00:37zezollolinkissue33934 messages
2018-06-21 16:00:37zezollocreate