Skip to content

Avoid locale dependent <ctype.h> functions like isascii(), isdigit(), tolower() #108767

Closed
@vstinner

Description

@vstinner

Feature or enhancement

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Proposal:

The following C files use <ctype.h> functions which depend on the current LC_CTYPE locale:

$ git grep -l -E '\b(isalnum|isalpha|iscntrl|isdigit|islower|isgraph|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper)\b'|grep -E '\.c$'
Modules/_decimal/libmpdec/io.c
Modules/_sre/sre.c
Modules/_zoneinfo.c
Modules/getaddrinfo.c
Objects/bytearrayobject.c
Objects/bytes_methods.c
Objects/bytesobject.c
Objects/unicodeobject.c
PC/launcher.c
PC/launcher2.c
Parser/tokenizer.c
Python/formatter_unicode.c
Python/pystrcmp.c

I propose to replace them with Python C API functions which don't depend on the locale, like Py_ISDIGIT() and Py_TOLOWER().

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions