[Python-checkins] cpython (3.2): Remove all other uses of the C tolower()/toupper() which could break with a

antoine.pitrou python-checkins at python.org
Tue Oct 4 13:56:36 CEST 2011


http://hg.python.org/cpython/rev/fe48e2b3dbee
changeset:   72655:fe48e2b3dbee
branch:      3.2
parent:      72652:469555867244
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Tue Oct 04 13:50:21 2011 +0200
summary:
  Remove all other uses of the C tolower()/toupper() which could break with a Turkish locale.

files:
  Modules/_tkinter.c    |  4 ++--
  Modules/binascii.c    |  4 ++--
  Modules/unicodedata.c |  4 ++--
  3 files changed, 6 insertions(+), 6 deletions(-)


diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -661,8 +661,8 @@
     }
 
     strcpy(argv0, className);
-    if (isupper(Py_CHARMASK(argv0[0])))
-        argv0[0] = tolower(Py_CHARMASK(argv0[0]));
+    if (Py_ISUPPER(Py_CHARMASK(argv0[0])))
+        argv0[0] = Py_TOLOWER(Py_CHARMASK(argv0[0]));
     Tcl_SetVar(v->interp, "argv0", argv0, TCL_GLOBAL_ONLY);
     ckfree(argv0);
 
diff --git a/Modules/binascii.c b/Modules/binascii.c
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -1102,8 +1102,8 @@
     if (isdigit(c))
         return c - '0';
     else {
-        if (isupper(c))
-            c = tolower(c);
+        if (Py_ISUPPER(c))
+            c = Py_TOLOWER(c);
         if (c >= 'a' && c <= 'f')
             return c - 'a' + 10;
     }
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -830,7 +830,7 @@
     unsigned long h = 0;
     unsigned long ix;
     for (i = 0; i < len; i++) {
-        h = (h * scale) + (unsigned char) toupper(Py_CHARMASK(s[i]));
+        h = (h * scale) + (unsigned char) Py_TOUPPER(Py_CHARMASK(s[i]));
         ix = h & 0xff000000;
         if (ix)
             h = (h ^ ((ix>>24) & 0xff)) & 0x00ffffff;
@@ -980,7 +980,7 @@
     if (!_getucname(self, code, buffer, sizeof(buffer)))
         return 0;
     for (i = 0; i < namelen; i++) {
-        if (toupper(Py_CHARMASK(name[i])) != buffer[i])
+        if (Py_TOUPPER(Py_CHARMASK(name[i])) != buffer[i])
             return 0;
     }
     return buffer[namelen] == '\0';

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list