summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2007-10-22 20:24:51 (GMT)
committerBrett Cannon <bcannon@gmail.com>2007-10-22 20:24:51 (GMT)
commit4043001f5d84d4919781e34221449047d0690ac8 (patch)
tree4b4db9f0b748407480aff4f10b99ce70548bfee0 /Objects
parent6464d471950c6ee109f82597ff70d755c127074f (diff)
downloadcpython-4043001f5d84d4919781e34221449047d0690ac8.zip
cpython-4043001f5d84d4919781e34221449047d0690ac8.tar.gz
cpython-4043001f5d84d4919781e34221449047d0690ac8.tar.bz2
Make str/str8 comparisons return True/False for !=/==.
Code that has been returning str8 becomes much more apparent thanks to this (e.g., struct module returning str8 for all string-related formats or sqlite3 passing in str8 instances when converting objects that had a __conform__ method). One also has to watch out in C code when making a key from char * using PyString in the C code but a str instance in Python code as that will not longer compare equal. Once str8 gains a constructor like the current bytes type then test_modulefinder needs a cleanup as the fix is a little messy in that file. Thanks goes to Thomas Lee for writing the patch for the change giving an initial run-down of why most of the tests were failing.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c10
1 files changed, 0 insertions, 10 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index fed2ff5..13644b0 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -6224,16 +6224,6 @@ int PyUnicode_Compare(PyObject *left,
if (PyUnicode_Check(left) && PyUnicode_Check(right))
return unicode_compare((PyUnicodeObject *)left,
(PyUnicodeObject *)right);
- if ((PyString_Check(left) && PyUnicode_Check(right)) ||
- (PyUnicode_Check(left) && PyString_Check(right))) {
- if (PyUnicode_Check(left))
- left = _PyUnicode_AsDefaultEncodedString(left, NULL);
- if (PyUnicode_Check(right))
- right = _PyUnicode_AsDefaultEncodedString(right, NULL);
- assert(PyString_Check(left));
- assert(PyString_Check(right));
- return PyObject_Compare(left, right);
- }
PyErr_Format(PyExc_TypeError,
"Can't compare %.100s and %.100s",
left->ob_type->tp_name,