summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-04-10 13:42:33 (GMT)
committerGuido van Rossum <guido@python.org>2000-04-10 13:42:33 (GMT)
commitb244f6950bd739a1d5dea7e119150e90ac03604f (patch)
tree755f3c4ee4f4f105c614b163ddfffbeac097cde9 /Objects
parent52c2359a590c7d96fc6b077a29df0f0840cdf90b (diff)
downloadcpython-b244f6950bd739a1d5dea7e119150e90ac03604f.zip
cpython-b244f6950bd739a1d5dea7e119150e90ac03604f.tar.gz
cpython-b244f6950bd739a1d5dea7e119150e90ac03604f.tar.bz2
Marc-Andre Lemburg:
* TypeErrors during comparing of mixed type arguments including a Unicode object are now masked (just like they are for all other combinations).
Diffstat (limited to 'Objects')
-rw-r--r--Objects/object.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 265ab9b..968fdd0 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -347,8 +347,21 @@ PyObject_Compare(v, w)
return cmp;
}
}
- else if (PyUnicode_Check(v) || PyUnicode_Check(w))
- return PyUnicode_Compare(v, w);
+ else if (PyUnicode_Check(v) || PyUnicode_Check(w)) {
+ int result = PyUnicode_Compare(v, w);
+ if (result == -1 && PyErr_Occurred() &&
+ PyErr_ExceptionMatches(PyExc_TypeError))
+ /* TypeErrors are ignored: if Unicode coercion
+ fails due to one of the arguments not
+ having the right type, we continue as
+ defined by the coercion protocol (see
+ above). Luckily, decoding errors are
+ reported as ValueErrors and are not masked
+ by this technique. */
+ PyErr_Clear();
+ else
+ return result;
+ }
else if (vtp->tp_as_number != NULL)
vname = "";
else if (wtp->tp_as_number != NULL)