diff options
author | Guido van Rossum <guido@python.org> | 2001-09-24 16:51:54 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-09-24 16:51:54 (GMT) |
commit | bb77e6801ea07653e3cc66dbfaa3b5102eae16e7 (patch) | |
tree | 99a4a2b967dad5571bd3c4b1a48ebdc75e01ab79 /Objects/stringobject.c | |
parent | ff0e6d6ef542b5b4f3c31786aa152cec68598d4f (diff) | |
download | cpython-bb77e6801ea07653e3cc66dbfaa3b5102eae16e7.zip cpython-bb77e6801ea07653e3cc66dbfaa3b5102eae16e7.tar.gz cpython-bb77e6801ea07653e3cc66dbfaa3b5102eae16e7.tar.bz2 |
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.
Diffstat (limited to 'Objects/stringobject.c')
-rw-r--r-- | Objects/stringobject.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 99a16ed..e29be5a 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -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; } |