STINNER Victor <vstin...@python.org> added the comment:
On Windows 10 build 1903, vstinner@WIN C:\vstinner\python\master>python -m test test_locale -m test_getsetlocale_issue1813 -v == CPython 3.10.0a6+ (heads/master:ff3c9739bd, Mar 31 2021, 12:43:26) [MSC v.1916 64 bit (AMD64)] == Windows-10-10.0.18362-SP0 little-endian (...) ====================================================================== ERROR: test_getsetlocale_issue1813 (test.test_locale.TestMiscellaneous) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\vstinner\python\master\lib\test\test_locale.py", line 567, in test_getsetlocale_issue1813 locale.setlocale(locale.LC_CTYPE, loc) File "C:\vstinner\python\master\lib\locale.py", line 610, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting It's a bug in the weird locale.getlocale() function which produces a locale name which doesn't exist: vstinner@WIN C:\vstinner\python\master>python >>> import locale >>> locale.setlocale(locale.LC_CTYPE, "tr_TR") 'tr_TR' >>> locale.setlocale(locale.LC_CTYPE, None) 'tr_TR' >>> locale.getlocale(locale.LC_CTYPE) ('tr_TR', 'ISO8859-9') >>> locale.setlocale(locale.LC_CTYPE, ('tr_TR', 'ISO8859-9')) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\vstinner\python\master\lib\locale.py", line 610, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting >>> locale.setlocale(locale.LC_CTYPE, 'tr_TR') 'tr_TR' If you use setlocale(LC_CTYPE, None) to get the locale, it works as expected. IMO the getlocale() function is dangerous and should be removed: see bpo-43557 "Deprecate getdefaultlocale(), getlocale() and normalize() functions". ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37945> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com