[New-bugs-announce] [issue17173] uses of locale-dependent ctype functions

Antoine Pitrou report at bugs.python.org
Sat Feb 9 21:49:59 CET 2013


New submission from Antoine Pitrou:

Grepping through the code reveals we are still using a number of locale-dependent C library functions:

Python/mystrtoul.c:102:    while (*str && isspace(Py_CHARMASK(*str)))
Python/mystrtoul.c:141:                while (isspace(Py_CHARMASK(*str)))
Python/mystrtoul.c:269:    while (*str && isspace(Py_CHARMASK(*str)))
Python/formatter_unicode.c:404:    while (pos<end && isdigit(PyUnicode_READ_CHAR(s, pos)))
Python/ast.c:3764:    if (isalpha(quote)) {
Python/dynload_aix.c:144:        while (isdigit(Py_CHARMASK(*message[i]))) message[i]++ ;
Objects/longobject.c:2011:    while (*str != '\0' && isspace(Py_CHARMASK(*str)))
Objects/longobject.c:2255:    while (*str && isspace(Py_CHARMASK(*str)))
Modules/getaddrinfo.c:228:        if (! isdigit(*q))
Modules/_sre.c:153:#define SRE_LOC_IS_DIGIT(ch) (!((ch) & ~255) ? isdigit((ch)) : 0)
Modules/_sre.c:154:#define SRE_LOC_IS_SPACE(ch) (!((ch) & ~255) ? isspace((ch)) : 0)
Modules/_sre.c:156:#define SRE_LOC_IS_ALNUM(ch) (!((ch) & ~255) ? isalnum((ch)) : 0)
Modules/binascii.c:1138:    if (isdigit(c))
Modules/_decimal/libmpdec/io.c:153:            if (!isdigit((uchar)*s))
Modules/_decimal/libmpdec/io.c:157:                    if (!isdigit((uchar)*(s+1)))
Modules/_decimal/libmpdec/io.c:159:                              isdigit((uchar)*(s+2))))
Modules/_decimal/libmpdec/io.c:185:    while (isdigit((uchar)*s))
Modules/_decimal/libmpdec/io.c:825:    if (isdigit((uchar)*cp)) {
Modules/_decimal/libmpdec/io.c:847:        if (!isdigit((uchar)*cp)) {
Modules/_decimal/libmpdec/io.c:1087:    assert(isdigit((uchar)*dp));
Modules/_decimal/libmpdec/io.c:1089:    while (isdigit((uchar)*dp)) {
Modules/_decimal/libmpdec/io.c:1244:    if (isupper((uchar)type)) {
Modules/_struct.c:1273:        if (isspace(Py_CHARMASK(c)))
Modules/_struct.c:1338:        if (isspace(Py_CHARMASK(c)))


Include/pyctype.h has locale-agnostic counterpart (a bit faster probably, too).

----------
components: Extension Modules, Interpreter Core
messages: 181759
nosy: mark.dickinson, pitrou, serhiy.storchaka, skrah
priority: normal
severity: normal
status: open
title: uses of locale-dependent ctype functions
type: behavior
versions: Python 3.2, Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17173>
_______________________________________


More information about the New-bugs-announce mailing list