summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-01-09 21:54:39 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-01-09 21:54:39 (GMT)
commitbb81c8ce3f9c879dac9975fcede878c3fb624002 (patch)
tree3f8ac796d69579053881046c62b5ab4a731a5b4a /Objects/unicodeobject.c
parentffeda291153942f643f2a73c6f1dde563c614e42 (diff)
downloadcpython-bb81c8ce3f9c879dac9975fcede878c3fb624002.zip
cpython-bb81c8ce3f9c879dac9975fcede878c3fb624002.tar.gz
cpython-bb81c8ce3f9c879dac9975fcede878c3fb624002.tar.bz2
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 ........
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 13db8c0..62bad6d 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -6932,6 +6932,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])