@@ -95,9 +95,7 @@ _Py_device_encoding(int fd)
9595#else
9696 if (_PyRuntime .preconfig .utf8_mode ) {
9797 _Py_DECLARE_STR (utf_8 , "utf-8" );
98- PyObject * encoding = & _Py_STR (utf_8 );
99- Py_INCREF (encoding );
100- return encoding ;
98+ return Py_NewRef (& _Py_STR (utf_8 ));
10199 }
102100 return _Py_GetLocaleEncodingObject ();
103101#endif
@@ -879,10 +877,10 @@ _Py_EncodeLocaleEx(const wchar_t *text, char **str,
879877
880878// Get the current locale encoding name:
881879//
882- // - Return "UTF -8" if _Py_FORCE_UTF8_LOCALE macro is defined (ex: on Android)
883- // - Return "UTF -8" if the UTF-8 Mode is enabled
880+ // - Return "utf -8" if _Py_FORCE_UTF8_LOCALE macro is defined (ex: on Android)
881+ // - Return "utf -8" if the UTF-8 Mode is enabled
884882// - On Windows, return the ANSI code page (ex: "cp1250")
885- // - Return "UTF -8" if nl_langinfo(CODESET) returns an empty string.
883+ // - Return "utf -8" if nl_langinfo(CODESET) returns an empty string.
886884// - Otherwise, return nl_langinfo(CODESET).
887885//
888886// Return NULL on memory allocation failure.
@@ -894,7 +892,7 @@ _Py_GetLocaleEncoding(void)
894892#ifdef _Py_FORCE_UTF8_LOCALE
895893 // On Android langinfo.h and CODESET are missing,
896894 // and UTF-8 is always used in mbstowcs() and wcstombs().
897- return _PyMem_RawWcsdup (L"UTF -8" );
895+ return _PyMem_RawWcsdup (L"utf -8" );
898896#else
899897
900898#ifdef MS_WINDOWS
@@ -908,7 +906,7 @@ _Py_GetLocaleEncoding(void)
908906 if (!encoding || encoding [0 ] == '\0' ) {
909907 // Use UTF-8 if nl_langinfo() returns an empty string. It can happen on
910908 // macOS if the LC_CTYPE locale is not supported.
911- return _PyMem_RawWcsdup (L"UTF -8" );
909+ return _PyMem_RawWcsdup (L"utf -8" );
912910 }
913911
914912 wchar_t * wstr ;
0 commit comments