mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Change string comparison so that it applies even when one (or both)
arguments are subclasses of str, as long as they don't override rich comparison.
This commit is contained in:
parent
ff0e6d6ef5
commit
bb77e6801e
2 changed files with 10 additions and 9 deletions
|
@ -824,9 +824,10 @@ string_richcompare(PyStringObject *a, PyStringObject *b, int op)
|
|||
int min_len;
|
||||
PyObject *result;
|
||||
|
||||
/* One of the objects is a string object. Make sure the
|
||||
other one is one, too. */
|
||||
if (a->ob_type != b->ob_type) {
|
||||
/* May sure both arguments use string comparison.
|
||||
This implies PyString_Check(a) && PyString_Check(b). */
|
||||
if (a->ob_type->tp_richcompare != (richcmpfunc)string_richcompare ||
|
||||
b->ob_type->tp_richcompare != (richcmpfunc)string_richcompare) {
|
||||
result = Py_NotImplemented;
|
||||
goto out;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue