summaryrefslogtreecommitdiffstats
path: root/Python/fileutils.c
diff options
context:
space:
mode:
authorMiss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com>2020-10-20 11:58:06 (GMT)
committerGitHub <noreply@github.com>2020-10-20 11:58:06 (GMT)
commit4cde523aa467c92a713674c793ab87e7c56486c4 (patch)
treebe9cd1a92551d5940442ae759d948cacfad9708f /Python/fileutils.c
parentd1eb75585ef4c108732ec815cdc0adef087b1c3e (diff)
downloadcpython-4cde523aa467c92a713674c793ab87e7c56486c4.zip
cpython-4cde523aa467c92a713674c793ab87e7c56486c4.tar.gz
cpython-4cde523aa467c92a713674c793ab87e7c56486c4.tar.bz2
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 f2312037e3a974d26ed3e23884f94c6af111a27a) Co-authored-by: TIGirardi <tiagoigirardi@gmail.com>
Diffstat (limited to 'Python/fileutils.c')
-rw-r--r--Python/fileutils.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/Python/fileutils.c b/Python/fileutils.c
index b274116..25516c2 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -1933,6 +1933,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;
@@ -1971,14 +1972,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;
}
@@ -1986,9 +1993,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
}