Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21ea21e

Browse files
committed
Issue #19424: PyUnicode_CompareWithASCIIString() normalizes memcmp() result
to -1, 0, 1
1 parent f0c7b2a commit 21ea21e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Objects/unicodeobject.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10584,8 +10584,12 @@ PyUnicode_CompareWithASCIIString(PyObject* uni, const char* str)
1058410584

1058510585
len = Py_MIN(len1, len2);
1058610586
cmp = memcmp(data, str, len);
10587-
if (cmp != 0)
10588-
return cmp;
10587+
if (cmp != 0) {
10588+
if (cmp < 0)
10589+
return -1;
10590+
else
10591+
return 1;
10592+
}
1058910593
if (len1 > len2)
1059010594
return 1; /* uni is longer */
1059110595
if (len2 > len1)

0 commit comments

Comments
 (0)