(original) (raw)

changeset: 82110:38830281d43b branch: 3.2 parent: 82107:cd59b398907d user: Antoine Pitrou solipsis@pitrou.net date: Sat Feb 09 23:11:27 2013 +0100 files: Misc/NEWS Modules/_struct.c Modules/binascii.c Modules/posixmodule.c Modules/socketmodule.c Objects/longobject.c Objects/stringlib/formatter.h Python/ast.c Python/dynload_aix.c Python/getargs.c Python/mystrtoul.c description: Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) in the interpreter. I've left a couple of them in: zlib (third-party lib), getaddrinfo.c (doesn't include Python.h, and probably obsolete), _sre.c (legitimate use for the re.LOCALE flag). diff -r cd59b398907d -r 38830281d43b Misc/NEWS --- a/Misc/NEWS Sat Feb 09 22:37:22 2013 +0200 +++ b/Misc/NEWS Sat Feb 09 23:11:27 2013 +0100 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) + in the interpreter. + - Issue #17043: The unicode-internal decoder no longer read past the end of input buffer. diff -r cd59b398907d -r 38830281d43b Modules/_struct.c --- a/Modules/_struct.c Sat Feb 09 22:37:22 2013 +0200 +++ b/Modules/_struct.c Sat Feb 09 23:11:27 2013 +0100 @@ -1184,7 +1184,7 @@ 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'; @@ -1249,7 +1249,7 @@ 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 -r cd59b398907d -r 38830281d43b Modules/binascii.c --- a/Modules/binascii.c Sat Feb 09 22:37:22 2013 +0200 +++ b/Modules/binascii.c Sat Feb 09 23:11:27 2013 +0100 @@ -1099,7 +1099,7 @@ static int to_int(int c) { - if (isdigit(c)) + if (Py_ISDIGIT(c)) return c - '0'; else { if (Py_ISUPPER(c)) diff -r cd59b398907d -r 38830281d43b Modules/posixmodule.c --- a/Modules/posixmodule.c Sat Feb 09 22:37:22 2013 +0200 +++ b/Modules/posixmodule.c Sat Feb 09 23:11:27 2013 +0100 @@ -695,7 +695,7 @@ 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 -r cd59b398907d -r 38830281d43b Modules/socketmodule.c --- a/Modules/socketmodule.c Sat Feb 09 22:37:22 2013 +0200 +++ b/Modules/socketmodule.c Sat Feb 09 23:11:27 2013 +0100 @@ -519,7 +519,7 @@ /* 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 -r cd59b398907d -r 38830281d43b Objects/longobject.c --- a/Objects/longobject.c Sat Feb 09 22:37:22 2013 +0200 +++ b/Objects/longobject.c Sat Feb 09 23:11:27 2013 +0100 @@ -1887,7 +1887,7 @@ "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; @@ -2131,7 +2131,7 @@ 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 -r cd59b398907d -r 38830281d43b Objects/stringlib/formatter.h --- a/Objects/stringlib/formatter.h Sat Feb 09 22:37:22 2013 +0200 +++ b/Objects/stringlib/formatter.h Sat Feb 09 23:11:27 2013 +0100 @@ -414,7 +414,7 @@ STRINGLIB_CHAR *end = ptr + len; STRINGLIB_CHAR *remainder; - while (ptr /* for isdigit() */ #include /* for global errno */ #include /* for strerror() */ #include /* for malloc(), free() */ @@ -144,7 +143,7 @@ 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 -r cd59b398907d -r 38830281d43b Python/getargs.c --- a/Python/getargs.c Sat Feb 09 22:37:22 2013 +0200 +++ b/Python/getargs.c Sat Feb 09 23:11:27 2013 +0100 @@ -288,7 +288,7 @@ if (level == 0) { if (c == 'O') max++; - else if (isalpha(Py_CHARMASK(c))) { + else if (Py_ISALPHA(Py_CHARMASK(c))) { if (c != 'e') /* skip encoded */ max++; } else if (c == '|') @@ -378,7 +378,7 @@ } } - if (*format != '\0' && !isalpha(Py_CHARMASK(*format)) && + if (*format != '\0' && !Py_ISALPHA(Py_CHARMASK(*format)) && *format != '(' && *format != '|' && *format != ':' && *format != ';') { PyErr_Format(PyExc_SystemError, @@ -471,7 +471,7 @@ } else if (c == ':' || c == ';' || c == '\0') break; - else if (level == 0 && isalpha(Py_CHARMASK(c))) + else if (level == 0 && Py_ISALPHA(Py_CHARMASK(c))) n++; } diff -r cd59b398907d -r 38830281d43b Python/mystrtoul.c --- a/Python/mystrtoul.c Sat Feb 09 22:37:22 2013 +0200 +++ b/Python/mystrtoul.c Sat Feb 09 23:11:27 2013 +0100 @@ -99,7 +99,7 @@ register int ovlimit; /* required digits to overflow */ /* skip leading white space */ - while (*str && isspace(Py_CHARMASK(*str))) + while (*str && Py_ISSPACE(Py_CHARMASK(*str))) ++str; /* check for leading 0b, 0o or 0x for auto-base or base 16 */ @@ -138,7 +138,7 @@ /* skip all zeroes... */ while (*str == '0') ++str; - while (isspace(Py_CHARMASK(*str))) + while (Py_ISSPACE(Py_CHARMASK(*str))) ++str; if (ptr) *ptr = str; @@ -266,7 +266,7 @@ unsigned long uresult; char sign; - while (*str && isspace(Py_CHARMASK(*str))) + while (*str && Py_ISSPACE(Py_CHARMASK(*str))) str++; sign = *str;/solipsis@pitrou.net