mirror of
https://github.com/python/cpython.git
synced 2025-07-08 03:45:36 +00:00
bpo-34523: Py_DecodeLocale() use UTF-8 on Windows (GH-8998)
Py_DecodeLocale() and Py_EncodeLocale() now use the UTF-8 encoding on Windows if Py_LegacyWindowsFSEncodingFlag is zero. pymain_read_conf() now sets Py_LegacyWindowsFSEncodingFlag in its loop, but restore its value at exit.
This commit is contained in:
parent
70fead25e5
commit
c5989cd876
5 changed files with 55 additions and 30 deletions
|
@ -499,9 +499,13 @@ _Py_DecodeLocaleEx(const char* arg, wchar_t **wstr, size_t *wlen,
|
|||
return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen, reason,
|
||||
surrogateescape);
|
||||
#else
|
||||
if (Py_UTF8Mode == 1) {
|
||||
return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen, reason,
|
||||
surrogateescape);
|
||||
int use_utf8 = (Py_UTF8Mode == 1);
|
||||
#ifdef MS_WINDOWS
|
||||
use_utf8 |= !Py_LegacyWindowsFSEncodingFlag;
|
||||
#endif
|
||||
if (use_utf8) {
|
||||
return _Py_DecodeUTF8Ex(arg, strlen(arg), wstr, wlen,
|
||||
reason, surrogateescape);
|
||||
}
|
||||
|
||||
#ifdef USE_FORCE_ASCII
|
||||
|
@ -661,7 +665,11 @@ encode_locale_ex(const wchar_t *text, char **str, size_t *error_pos,
|
|||
return _Py_EncodeUTF8Ex(text, str, error_pos, reason,
|
||||
raw_malloc, surrogateescape);
|
||||
#else /* __APPLE__ */
|
||||
if (Py_UTF8Mode == 1) {
|
||||
int use_utf8 = (Py_UTF8Mode == 1);
|
||||
#ifdef MS_WINDOWS
|
||||
use_utf8 |= !Py_LegacyWindowsFSEncodingFlag;
|
||||
#endif
|
||||
if (use_utf8) {
|
||||
return _Py_EncodeUTF8Ex(text, str, error_pos, reason,
|
||||
raw_malloc, surrogateescape);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue