diff --git a/Misc/NEWS b/Misc/NEWS index 7d3fc94fa1d..7dfca9197fe 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ What's New in Python 3.3.1? Core and Builtins ----------------- +- Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) + in the interpreter. + - Issue #17137: When an Unicode string is resized, the internal wide character string (wstr) format is now cleared. diff --git a/Modules/_struct.c b/Modules/_struct.c index 0cd0512dcf5..28486140f11 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1271,7 +1271,7 @@ prepare_s(PyStructObject *self) size = 0; len = 0; while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) + if (Py_ISSPACE(Py_CHARMASK(c))) continue; if ('0' <= c && c <= '9') { num = c - '0'; @@ -1336,7 +1336,7 @@ prepare_s(PyStructObject *self) s = fmt; size = 0; while ((c = *s++) != '\0') { - if (isspace(Py_CHARMASK(c))) + if (Py_ISSPACE(Py_CHARMASK(c))) continue; if ('0' <= c && c <= '9') { num = c - '0'; diff --git a/Modules/binascii.c b/Modules/binascii.c index ad5e1b1a1c1..340ec9c4260 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -1135,7 +1135,7 @@ This function is also available as \"hexlify()\"."); static int to_int(int c) { - if (isdigit(c)) + if (Py_ISDIGIT(c)) return c - '0'; else { if (Py_ISUPPER(c)) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 40645ea71aa..f2bbd9de749 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1172,7 +1172,7 @@ os2_formatmsg(char *msgbuf, int msglen, char *reason) if (strlen(msgbuf) > 0) { /* If Non-Empty Msg, Trim CRLF */ char *lastc = &msgbuf[ strlen(msgbuf)-1 ]; - while (lastc > msgbuf && isspace(Py_CHARMASK(*lastc))) + while (lastc > msgbuf && Py_ISSPACE(Py_CHARMASK(*lastc))) *lastc-- = '\0'; /* Trim Trailing Whitespace (CRLF) */ } diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index d7aef8f9837..41982070ed2 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -555,7 +555,7 @@ set_error(void) /* If non-empty msg, trim CRLF */ char *lastc = &outbuf[ strlen(outbuf)-1 ]; while (lastc > outbuf && - isspace(Py_CHARMASK(*lastc))) { + Py_ISSPACE(Py_CHARMASK(*lastc))) { /* Trim trailing whitespace (CRLF) */ *lastc-- = '\0'; } diff --git a/Objects/longobject.c b/Objects/longobject.c index 32ccdc39276..d4dc45a23bc 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -2019,7 +2019,7 @@ PyLong_FromString(char *str, char **pend, int base) "int() arg 2 must be >= 2 and <= 36"); return NULL; } - while (*str != '\0' && isspace(Py_CHARMASK(*str))) + while (*str != '\0' && Py_ISSPACE(Py_CHARMASK(*str))) str++; if (*str == '+') ++str; @@ -2263,7 +2263,7 @@ digit beyond the first. goto onError; if (sign < 0) Py_SIZE(z) = -(Py_SIZE(z)); - while (*str && isspace(Py_CHARMASK(*str))) + while (*str && Py_ISSPACE(Py_CHARMASK(*str))) str++; if (*str != '\0') goto onError; diff --git a/Python/ast.c b/Python/ast.c index 7657b22459f..730c576e4ee 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -3747,7 +3747,7 @@ parsestr(struct compiling *c, const node *n, int *bytesmode) int quote = Py_CHARMASK(*s); int rawmode = 0; int need_encoding; - if (isalpha(quote)) { + if (Py_ISALPHA(quote)) { while (!*bytesmode || !rawmode) { if (quote == 'b' || quote == 'B') { quote = *++s; diff --git a/Python/dynload_aix.c b/Python/dynload_aix.c index b4f71f291a1..f40a0be65b1 100644 --- a/Python/dynload_aix.c +++ b/Python/dynload_aix.c @@ -4,7 +4,6 @@ #include "Python.h" #include "importdl.h" -#include /* for isdigit() */ #include /* for global errno */ #include /* for strerror() */ #include /* for malloc(), free() */ @@ -141,7 +140,7 @@ aix_loaderror(const char *pathname) if (nerr == load_errtab[j].errNo && load_errtab[j].errstr) ERRBUF_APPEND(load_errtab[j].errstr); } - while (isdigit(Py_CHARMASK(*message[i]))) message[i]++ ; + while (Py_ISDIGIT(Py_CHARMASK(*message[i]))) message[i]++ ; ERRBUF_APPEND(message[i]); ERRBUF_APPEND("\n"); } diff --git a/Python/formatter_unicode.c b/Python/formatter_unicode.c index aa62502dbef..17eb9789e04 100644 --- a/Python/formatter_unicode.c +++ b/Python/formatter_unicode.c @@ -401,7 +401,7 @@ parse_number(PyObject *s, Py_ssize_t pos, Py_ssize_t end, { Py_ssize_t remainder; - while (pos