Mercurial > cpython-lru_cache-weakref
diff Objects/unicodeobject.c @ 58224:ab88daa4d2ce
Python strings ending with '\0' should not be equivalent to their C counterparts in PyUnicode_CompareWithASCIIString
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 09 Jan 2010 21:45:28 +0000 |
| parents | ac768c8e13ac |
| children | 5ca1948a8fd6 |
line wrap: on
line diff
--- a/Objects/unicodeobject.c Sat Jan 09 20:35:09 2010 +0000 +++ b/Objects/unicodeobject.c Sat Jan 09 21:45:28 2010 +0000 @@ -7001,6 +7001,11 @@ 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])
