diff Python/_warnings.c @ 74341:c2153ce1b5dd

remove some usage of Py_UNICODE_TOUPPER/LOWER
author Benjamin Peterson <benjamin@python.org>
date Wed, 11 Jan 2012 21:00:42 -0500
parents b7c5e30582d1
children c19b0ae5cd91
line wrap: on
line diff
--- a/Python/_warnings.c	Wed Jan 11 18:17:40 2012 -0500
+++ b/Python/_warnings.c	Wed Jan 11 21:00:42 2012 -0500
@@ -510,13 +510,14 @@
         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);