summaryrefslogtreecommitdiffstats
path: root/Python/_warnings.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-01-12 02:00:42 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-01-12 02:00:42 (GMT)
commit21e0da228d158ec248be5c7db274a7bc54a51307 (patch)
tree0982086d2e9631949626820ee61dac8d4b8482cb /Python/_warnings.c
parent22ef4fa7e9805312c83b595b27218443c367dcd0 (diff)
downloadcpython-21e0da228d158ec248be5c7db274a7bc54a51307.zip
cpython-21e0da228d158ec248be5c7db274a7bc54a51307.tar.gz
cpython-21e0da228d158ec248be5c7db274a7bc54a51307.tar.bz2
remove some usage of Py_UNICODE_TOUPPER/LOWER
Diffstat (limited to 'Python/_warnings.c')
-rw-r--r--Python/_warnings.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 458e346..adebd51 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -510,13 +510,14 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
kind = PyUnicode_KIND(*filename);
data = PyUnicode_DATA(*filename);
+#define ascii_lower(c) ((c <= 127) ? Py_TOLOWER(c) : 0)
/* if filename.lower().endswith((".pyc", ".pyo")): */
if (len >= 4 &&
PyUnicode_READ(kind, data, len-4) == '.' &&
- Py_UNICODE_TOLOWER(PyUnicode_READ(kind, data, len-3)) == 'p' &&
- Py_UNICODE_TOLOWER(PyUnicode_READ(kind, data, len-2)) == 'y' &&
- (Py_UNICODE_TOLOWER(PyUnicode_READ(kind, data, len-1)) == 'c' ||
- Py_UNICODE_TOLOWER(PyUnicode_READ(kind, data, len-1)) == 'o'))
+ ascii_lower(PyUnicode_READ(kind, data, len-3)) == 'p' &&
+ ascii_lower(PyUnicode_READ(kind, data, len-2)) == 'y' &&
+ (ascii_lower(PyUnicode_READ(kind, data, len-1)) == 'c' ||
+ ascii_lower(PyUnicode_READ(kind, data, len-1)) == 'o'))
{
*filename = PyUnicode_Substring(*filename, 0,
PyUnicode_GET_LENGTH(*filename)-1);