gh-108767: Replace ctype.h functions with pyctype.h functions#108772
gh-108767: Replace ctype.h functions with pyctype.h functions#108772vstinner merged 2 commits intopython:mainfrom
Conversation
Replace <ctype.h> locale dependent functions with Python "pyctype.h" locale independent functions: * Replace isalpha() with Py_ISALPHA(). * Replace isdigit() with Py_ISDIGIT(). * Replace isxdigit() with Py_ISXDIGIT(). * Replace tolower() with Py_TOLOWER(). Leave Modules/_sre/sre.c unchanged, it uses locale dependent functions on purpose.
On Linux, they don't seem to be locale dependent: But I prefer to avoid <ctype.h> functions anyway, just in case. |
* Include explicitly <ctype.h> in _decimal.c to get isascii().
|
Merged. Thanks for the review @serhiy-storchaka. I'm not sure that there is currently a bug being solved here, so in case of doubt, I prefer to not backport the change. This change is more to help me reducing the number of standard header files included by |
|
I have been thinking about making these changes for a long time, but there were always more urgent matters. So thank you for doing this. There was a possible pitfall if the argument is EOF or larger than 255. But I checked and found no such cases. |
|
At least, pyctype.h has no undefined behavior, but a well defined behaviors for these values, no? See PR #108770 which seems to be a more hairy problem than expected! |
|
It also fixes #86842. |
Replace <ctype.h> locale dependent functions with Python "pyctype.h" locale independent functions:
Leave Modules/_sre/sre.c unchanged, it uses locale dependent functions on purpose.