mirror of https://github.com/python/cpython
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), mpdecimal (needs to build without Python.h).
This commit is contained in:
commit
c73c561181
|
@ -12,6 +12,9 @@ What's New in Python 3.3.1?
|
||||||
Core and Builtins
|
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
|
- Issue #17137: When an Unicode string is resized, the internal wide character
|
||||||
string (wstr) format is now cleared.
|
string (wstr) format is now cleared.
|
||||||
|
|
||||||
|
|
|
@ -1271,7 +1271,7 @@ prepare_s(PyStructObject *self)
|
||||||
size = 0;
|
size = 0;
|
||||||
len = 0;
|
len = 0;
|
||||||
while ((c = *s++) != '\0') {
|
while ((c = *s++) != '\0') {
|
||||||
if (isspace(Py_CHARMASK(c)))
|
if (Py_ISSPACE(Py_CHARMASK(c)))
|
||||||
continue;
|
continue;
|
||||||
if ('0' <= c && c <= '9') {
|
if ('0' <= c && c <= '9') {
|
||||||
num = c - '0';
|
num = c - '0';
|
||||||
|
@ -1336,7 +1336,7 @@ prepare_s(PyStructObject *self)
|
||||||
s = fmt;
|
s = fmt;
|
||||||
size = 0;
|
size = 0;
|
||||||
while ((c = *s++) != '\0') {
|
while ((c = *s++) != '\0') {
|
||||||
if (isspace(Py_CHARMASK(c)))
|
if (Py_ISSPACE(Py_CHARMASK(c)))
|
||||||
continue;
|
continue;
|
||||||
if ('0' <= c && c <= '9') {
|
if ('0' <= c && c <= '9') {
|
||||||
num = c - '0';
|
num = c - '0';
|
||||||
|
|
|
@ -1135,7 +1135,7 @@ This function is also available as \"hexlify()\".");
|
||||||
static int
|
static int
|
||||||
to_int(int c)
|
to_int(int c)
|
||||||
{
|
{
|
||||||
if (isdigit(c))
|
if (Py_ISDIGIT(c))
|
||||||
return c - '0';
|
return c - '0';
|
||||||
else {
|
else {
|
||||||
if (Py_ISUPPER(c))
|
if (Py_ISUPPER(c))
|
||||||
|
|
|
@ -1172,7 +1172,7 @@ os2_formatmsg(char *msgbuf, int msglen, char *reason)
|
||||||
if (strlen(msgbuf) > 0) { /* If Non-Empty Msg, Trim CRLF */
|
if (strlen(msgbuf) > 0) { /* If Non-Empty Msg, Trim CRLF */
|
||||||
char *lastc = &msgbuf[ strlen(msgbuf)-1 ];
|
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) */
|
*lastc-- = '\0'; /* Trim Trailing Whitespace (CRLF) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -555,7 +555,7 @@ set_error(void)
|
||||||
/* If non-empty msg, trim CRLF */
|
/* If non-empty msg, trim CRLF */
|
||||||
char *lastc = &outbuf[ strlen(outbuf)-1 ];
|
char *lastc = &outbuf[ strlen(outbuf)-1 ];
|
||||||
while (lastc > outbuf &&
|
while (lastc > outbuf &&
|
||||||
isspace(Py_CHARMASK(*lastc))) {
|
Py_ISSPACE(Py_CHARMASK(*lastc))) {
|
||||||
/* Trim trailing whitespace (CRLF) */
|
/* Trim trailing whitespace (CRLF) */
|
||||||
*lastc-- = '\0';
|
*lastc-- = '\0';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2019,7 +2019,7 @@ PyLong_FromString(char *str, char **pend, int base)
|
||||||
"int() arg 2 must be >= 2 and <= 36");
|
"int() arg 2 must be >= 2 and <= 36");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
while (*str != '\0' && isspace(Py_CHARMASK(*str)))
|
while (*str != '\0' && Py_ISSPACE(Py_CHARMASK(*str)))
|
||||||
str++;
|
str++;
|
||||||
if (*str == '+')
|
if (*str == '+')
|
||||||
++str;
|
++str;
|
||||||
|
@ -2263,7 +2263,7 @@ digit beyond the first.
|
||||||
goto onError;
|
goto onError;
|
||||||
if (sign < 0)
|
if (sign < 0)
|
||||||
Py_SIZE(z) = -(Py_SIZE(z));
|
Py_SIZE(z) = -(Py_SIZE(z));
|
||||||
while (*str && isspace(Py_CHARMASK(*str)))
|
while (*str && Py_ISSPACE(Py_CHARMASK(*str)))
|
||||||
str++;
|
str++;
|
||||||
if (*str != '\0')
|
if (*str != '\0')
|
||||||
goto onError;
|
goto onError;
|
||||||
|
|
|
@ -3747,7 +3747,7 @@ parsestr(struct compiling *c, const node *n, int *bytesmode)
|
||||||
int quote = Py_CHARMASK(*s);
|
int quote = Py_CHARMASK(*s);
|
||||||
int rawmode = 0;
|
int rawmode = 0;
|
||||||
int need_encoding;
|
int need_encoding;
|
||||||
if (isalpha(quote)) {
|
if (Py_ISALPHA(quote)) {
|
||||||
while (!*bytesmode || !rawmode) {
|
while (!*bytesmode || !rawmode) {
|
||||||
if (quote == 'b' || quote == 'B') {
|
if (quote == 'b' || quote == 'B') {
|
||||||
quote = *++s;
|
quote = *++s;
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "importdl.h"
|
#include "importdl.h"
|
||||||
|
|
||||||
#include <ctype.h> /* for isdigit() */
|
|
||||||
#include <errno.h> /* for global errno */
|
#include <errno.h> /* for global errno */
|
||||||
#include <string.h> /* for strerror() */
|
#include <string.h> /* for strerror() */
|
||||||
#include <stdlib.h> /* for malloc(), free() */
|
#include <stdlib.h> /* for malloc(), free() */
|
||||||
|
@ -141,7 +140,7 @@ aix_loaderror(const char *pathname)
|
||||||
if (nerr == load_errtab[j].errNo && load_errtab[j].errstr)
|
if (nerr == load_errtab[j].errNo && load_errtab[j].errstr)
|
||||||
ERRBUF_APPEND(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(message[i]);
|
||||||
ERRBUF_APPEND("\n");
|
ERRBUF_APPEND("\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -401,7 +401,7 @@ parse_number(PyObject *s, Py_ssize_t pos, Py_ssize_t end,
|
||||||
{
|
{
|
||||||
Py_ssize_t remainder;
|
Py_ssize_t remainder;
|
||||||
|
|
||||||
while (pos<end && isdigit(PyUnicode_READ_CHAR(s, pos)))
|
while (pos<end && Py_ISDIGIT(PyUnicode_READ_CHAR(s, pos)))
|
||||||
++pos;
|
++pos;
|
||||||
remainder = pos;
|
remainder = pos;
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags)
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
if (c == 'O')
|
if (c == 'O')
|
||||||
max++;
|
max++;
|
||||||
else if (isalpha(Py_CHARMASK(c))) {
|
else if (Py_ISALPHA(Py_CHARMASK(c))) {
|
||||||
if (c != 'e') /* skip encoded */
|
if (c != 'e') /* skip encoded */
|
||||||
max++;
|
max++;
|
||||||
} else if (c == '|')
|
} else if (c == '|')
|
||||||
|
@ -336,7 +336,7 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*format != '\0' && !isalpha(Py_CHARMASK(*format)) &&
|
if (*format != '\0' && !Py_ISALPHA(Py_CHARMASK(*format)) &&
|
||||||
*format != '(' &&
|
*format != '(' &&
|
||||||
*format != '|' && *format != ':' && *format != ';') {
|
*format != '|' && *format != ':' && *format != ';') {
|
||||||
PyErr_Format(PyExc_SystemError,
|
PyErr_Format(PyExc_SystemError,
|
||||||
|
@ -429,7 +429,7 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
||||||
}
|
}
|
||||||
else if (c == ':' || c == ';' || c == '\0')
|
else if (c == ':' || c == ';' || c == '\0')
|
||||||
break;
|
break;
|
||||||
else if (level == 0 && isalpha(Py_CHARMASK(c)))
|
else if (level == 0 && Py_ISALPHA(Py_CHARMASK(c)))
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
|
||||||
register int ovlimit; /* required digits to overflow */
|
register int ovlimit; /* required digits to overflow */
|
||||||
|
|
||||||
/* skip leading white space */
|
/* skip leading white space */
|
||||||
while (*str && isspace(Py_CHARMASK(*str)))
|
while (*str && Py_ISSPACE(Py_CHARMASK(*str)))
|
||||||
++str;
|
++str;
|
||||||
|
|
||||||
/* check for leading 0b, 0o or 0x for auto-base or base 16 */
|
/* check for leading 0b, 0o or 0x for auto-base or base 16 */
|
||||||
|
@ -138,7 +138,7 @@ PyOS_strtoul(register char *str, char **ptr, int base)
|
||||||
/* skip all zeroes... */
|
/* skip all zeroes... */
|
||||||
while (*str == '0')
|
while (*str == '0')
|
||||||
++str;
|
++str;
|
||||||
while (isspace(Py_CHARMASK(*str)))
|
while (Py_ISSPACE(Py_CHARMASK(*str)))
|
||||||
++str;
|
++str;
|
||||||
if (ptr)
|
if (ptr)
|
||||||
*ptr = str;
|
*ptr = str;
|
||||||
|
@ -266,7 +266,7 @@ PyOS_strtol(char *str, char **ptr, int base)
|
||||||
unsigned long uresult;
|
unsigned long uresult;
|
||||||
char sign;
|
char sign;
|
||||||
|
|
||||||
while (*str && isspace(Py_CHARMASK(*str)))
|
while (*str && Py_ISSPACE(Py_CHARMASK(*str)))
|
||||||
str++;
|
str++;
|
||||||
|
|
||||||
sign = *str;
|
sign = *str;
|
||||||
|
|
Loading…
Reference in New Issue