From 21ea21ef6db731a8cac14fcd0c1a12c5c44496f4 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 4 Nov 2013 11:28:26 +0100 Subject: [PATCH] Issue #19424: PyUnicode_CompareWithASCIIString() normalizes memcmp() result to -1, 0, 1 --- Objects/unicodeobject.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 154103dfea3..574b57a259f 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -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)