Marc-Andre Lemburg <m...@egenix.com> added the comment:
On 17.02.2021 12:36, Anders Munch wrote: > getlocale is documented to return None for the encoding if no encoding can be > determined. There's no need to guess. Well, not quite... the documentation says that None can be returned, not that it will return None in such cases. What happens is that the value returned by the C lib's setlocale() is normalized and parsed. If it doesn't include an encoding, the table locale_alias is used to provide an encoding. If this table does not include the locale, you get the ValueError. We could enhance this to return None for the encoding instead of raising an exception, but would this really help ? Alternatively, we could add "en_DE" to the alias table and set a default encoding to use. I assume this would have to be ISO8859-15. OTOH, Windows supports UTF-8 for all locales in more recent Windows versions, so perhaps we should use UTF-8 instead. BTW: What is wxWidgets doing with the returned values ? Resources: - setlocale() in Visual C++ on Windows: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-160 - locale name formats supported by Windows CRT: https://docs.microsoft.com/en-us/cpp/c-runtime-library/locale-names-languages-and-country-region-strings?view=msvc-160 - Language locale tags known by Windows: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/a9eac961-e77d-41a6-90a5-ce1a8b0cdb9c - UTF8 support in Windows CRT: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-160#utf-8-support ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue43115> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com