summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-16 08:02:45 (GMT)
committerGuido van Rossum <guido@python.org>2001-08-16 08:02:45 (GMT)
commit82fc51c19c90ea7a9aab0aac8db278a84cefe2b1 (patch)
treeb5714e2c6dd81cdecbbf06892ea8062d89644157 /Objects
parent49b253b17360908ede3d0e036cd8414a382c708a (diff)
downloadcpython-82fc51c19c90ea7a9aab0aac8db278a84cefe2b1.zip
cpython-82fc51c19c90ea7a9aab0aac8db278a84cefe2b1.tar.gz
cpython-82fc51c19c90ea7a9aab0aac8db278a84cefe2b1.tar.bz2
Update to MvL's patch #424475 to avoid returning 2 when tp_compare
returns that. (This fix is also by MvL; checkin it in because I want to make more changes here. I'm still not 100% satisfied -- see comments attached to the patch.)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/object.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 0d9b3fe..e602159 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -580,8 +580,11 @@ do_cmp(PyObject *v, PyObject *w)
cmpfunc f;
if (v->ob_type == w->ob_type
- && (f = v->ob_type->tp_compare) != NULL)
- return (*f)(v, w);
+ && (f = v->ob_type->tp_compare) != NULL) {
+ c = (*f)(v, w);
+ if (c != 2 || !PyInstance_Check(v))
+ return c;
+ }
c = try_rich_to_3way_compare(v, w);
if (c < 2)
return c;