mirror of
https://github.com/python/cpython.git
synced 2025-07-18 08:45:20 +00:00
bpo-38324: Fix test__locale.py Windows failures (GH-20529)
Use wide-char _W_* fields of lconv structure on Windows
Remove "ps_AF" from test__locale.known_numerics on Windows
(cherry picked from commit f2312037e3
)
Co-authored-by: TIGirardi <tiagoigirardi@gmail.com>
This commit is contained in:
parent
3fc7080220
commit
c17ff5cad2
4 changed files with 40 additions and 5 deletions
|
@ -2032,6 +2032,7 @@ _Py_GetLocaleconvNumeric(struct lconv *lc,
|
|||
assert(decimal_point != NULL);
|
||||
assert(thousands_sep != NULL);
|
||||
|
||||
#ifndef MS_WINDOWS
|
||||
int change_locale = 0;
|
||||
if ((strlen(lc->decimal_point) > 1 || ((unsigned char)lc->decimal_point[0]) > 127)) {
|
||||
change_locale = 1;
|
||||
|
@ -2070,14 +2071,20 @@ _Py_GetLocaleconvNumeric(struct lconv *lc,
|
|||
}
|
||||
}
|
||||
|
||||
#define GET_LOCALE_STRING(ATTR) PyUnicode_DecodeLocale(lc->ATTR, NULL)
|
||||
#else /* MS_WINDOWS */
|
||||
/* Use _W_* fields of Windows strcut lconv */
|
||||
#define GET_LOCALE_STRING(ATTR) PyUnicode_FromWideChar(lc->_W_ ## ATTR, -1)
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
int res = -1;
|
||||
|
||||
*decimal_point = PyUnicode_DecodeLocale(lc->decimal_point, NULL);
|
||||
*decimal_point = GET_LOCALE_STRING(decimal_point);
|
||||
if (*decimal_point == NULL) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
*thousands_sep = PyUnicode_DecodeLocale(lc->thousands_sep, NULL);
|
||||
*thousands_sep = GET_LOCALE_STRING(thousands_sep);
|
||||
if (*thousands_sep == NULL) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -2085,9 +2092,13 @@ _Py_GetLocaleconvNumeric(struct lconv *lc,
|
|||
res = 0;
|
||||
|
||||
done:
|
||||
#ifndef MS_WINDOWS
|
||||
if (loc != NULL) {
|
||||
setlocale(LC_CTYPE, oldloc);
|
||||
}
|
||||
PyMem_Free(oldloc);
|
||||
#endif
|
||||
return res;
|
||||
|
||||
#undef GET_LOCALE_STRING
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue