mirror of
https://github.com/python/cpython.git
synced 2025-08-28 20:56:54 +00:00
Python strings ending with '\0' should not be equivalent to their C counterparts in PyUnicode_CompareWithASCIIString
This commit is contained in:
parent
c36c3789de
commit
8667a9b6ea
3 changed files with 26 additions and 0 deletions
|
@ -7001,6 +7001,11 @@ PyUnicode_CompareWithASCIIString(PyObject* uni, const char* str)
|
|||
for (i = 0; id[i] && str[i]; i++)
|
||||
if (id[i] != str[i])
|
||||
return ((int)id[i] < (int)str[i]) ? -1 : 1;
|
||||
/* This check keeps Python strings that end in '\0' from comparing equal
|
||||
to C strings identical up to that point. */
|
||||
if (PyUnicode_GET_SIZE(uni) != i)
|
||||
/* We'll say the Python string is longer. */
|
||||
return 1;
|
||||
if (id[i])
|
||||
return 1; /* uni is longer */
|
||||
if (str[i])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue