]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #19424: PyUnicode_CompareWithASCIIString() normalizes memcmp() result
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 4 Nov 2013 10:28:26 +0000 (11:28 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 4 Nov 2013 10:28:26 +0000 (11:28 +0100)
to -1, 0, 1

Objects/unicodeobject.c

index 154103dfea312337306febd45bca7c23014ae46c..574b57a259f2c41ef172a51e916c69fd83497c6b 100644 (file)
@@ -10584,8 +10584,12 @@ PyUnicode_CompareWithASCIIString(PyObject* uni, const char* str)
 
         len = Py_MIN(len1, len2);
         cmp = memcmp(data, str, len);
-        if (cmp != 0)
-            return cmp;
+        if (cmp != 0) {
+            if (cmp < 0)
+                return -1;
+            else
+                return 1;
+        }
         if (len1 > len2)
             return 1; /* uni is longer */
         if (len2 > len1)