[issue25812] locale.nl_langinfo() can't decode value

2019-01-09 Thread STINNER Victor


STINNER Victor  added the comment:

Since this bug has been reported, locale.localeconv() has been fixed in 
bpo-31900 to temporarily set LC_CTYPE to LC_NUMERIC to decode numeric fields of 
localeconv() from the proper encoding. I guess that a similar fix can be 
applied to locale.nl_langinfo(): set LC_CTYPE to LC_NUMERIC if the parameter is 
a numeric field.

I only knew locale.nl_langinfo(locale.CODESET). I didn't know that this 
function accepted other arguments :-)

I even wrote an article about these locale bugs :-)
https://github.com/python/cpython/pull/5191

See also bpo-35697: "decimal: formatter error if LC_NUMERIC uses a different 
encoding than LC_CTYPE".

--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25812] locale.nl_langinfo() can't decode value

2018-09-28 Thread Barry A. Warsaw


Change by Barry A. Warsaw :


--
assignee:  -> nnja

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25812] locale.nl_langinfo() can't decode value

2018-09-28 Thread Barry A. Warsaw


Change by Barry A. Warsaw :


--
nosy: +barry

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25812] locale.nl_langinfo() can't decode value

2018-09-28 Thread Barry A. Warsaw


Change by Barry A. Warsaw :


--
versions: +Python 3.8 -Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25812] locale.nl_langinfo() can't decode value

2016-06-03 Thread R. David Murray

R. David Murray added the comment:

Thanks, Nina.  We do have support in test.support for running a test with a 
specific locale (run_with_locale), so this could be turned into a unit test 
patch if you or someone else is willing to do that.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25812] locale.nl_langinfo() can't decode value

2016-06-02 Thread Nina Zakharenko

Nina Zakharenko added the comment:

Adding the test below to test__locale.py will reproduce the issue under the 
following conditions:
- The locale `uk_UA` is installed on your system.
- 'uk_UA': (',', '\xa0') is added to the `known_numerics` dictionary in this 
test file

@unittest.skipUnless(nl_langinfo, "nl_langinfo is not available")
def test_lc_numeric_not_char_nl_langinfo(self):
# Test nl_langinfo against known values/
# It should still work if there's a mismatch between
# String & Numeric Locales
tested = False
for loc in candidate_locales:
try:
setlocale(LC_NUMERIC, loc)
except Error:
continue
for li, lc in ((RADIXCHAR, "decimal_point"),
(THOUSEP, "thousands_sep")):
if self.numeric_tester('nl_langinfo', nl_langinfo(li), lc, loc):
tested = True
if not tested:
self.skipTest('no suitable locales')

--
nosy: +nnja

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25812] locale.nl_langinfo() can't decode value

2015-12-05 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

>>> import locale
>>> locale.setlocale(locale.LC_NUMERIC, 'uk_UA')
'uk_UA'
>>> locale.getlocale(locale.LC_NUMERIC)
('uk_UA', 'KOI8-U')
>>> locale.nl_langinfo(locale.THOUSEP)
Traceback (most recent call last):
  File "", line 1, in 
UnicodeDecodeError: 'locale' codec can't decode byte 0x9a in position 0: 
Invalid or incomplete multibyte or wide character

Looks as locale.nl_langinfo() always uses the UTF-8 encoding (or may be 
locale.getpreferredencoding()).

--
components: Library (Lib)
messages: 255979
nosy: lemburg, loewis, serhiy.storchaka
priority: normal
severity: normal
status: open
title: locale.nl_langinfo() can't decode value
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com