diff Objects/unicodeobject.c @ 58226:c1bec2db1fcd 3.1

Merged revisions 77395 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r77395 | benjamin.peterson | 2010-01-09 15:45:28 -0600 (Sat, 09 Jan 2010) | 2 lines 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:54:39 +0000
parents b085fd0611de
children 235933d4da8e
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Sat Jan 09 18:48:46 2010 +0000
+++ b/Objects/unicodeobject.c	Sat Jan 09 21:54:39 2010 +0000
@@ -6932,6 +6932,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])