]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
unicode_fromascii() doesn't check string content twice in debug mode
authorVictor Stinner <victor.stinner@haypocalc.com>
Sun, 11 Dec 2011 20:54:30 +0000 (21:54 +0100)
committerVictor Stinner <victor.stinner@haypocalc.com>
Sun, 11 Dec 2011 20:54:30 +0000 (21:54 +0100)
_PyUnicode_CheckConsistency() also checks string content.

Objects/unicodeobject.c

index 8d04ea40cddbc274b00129b38b8ba992c7a7f9c2..d6a250e30e2a50f69799d20972a0511f40ee1cef 100644 (file)
@@ -1768,15 +1768,12 @@ static PyObject*
 unicode_fromascii(const unsigned char* s, Py_ssize_t size)
 {
     PyObject *unicode;
+    if (size == 1) {
 #ifdef Py_DEBUG
-    const unsigned char *p;
-    const unsigned char *end = s + size;
-    for (p=s; p < end; p++) {
-        assert(*p < 128);
-    }
+        assert(s[0] < 128);
 #endif
-    if (size == 1)
         return get_latin1_char(s[0]);
+    }
     unicode = PyUnicode_New(size, 127);
     if (!unicode)
         return NULL;