summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSjoerd Mullender <sjoerd@acm.org>1994-10-19 15:11:52 (GMT)
committerSjoerd Mullender <sjoerd@acm.org>1994-10-19 15:11:52 (GMT)
commitb9a6d1249894c60eb38d3cc8ce4c1b808482b377 (patch)
treec9945b09e01635fc919603d9df9a85cb6eeea9e4 /Objects
parent2abc49458bd8e847c956baf33c188f5716039bf8 (diff)
downloadcpython-b9a6d1249894c60eb38d3cc8ce4c1b808482b377.zip
cpython-b9a6d1249894c60eb38d3cc8ce4c1b808482b377.tar.gz
cpython-b9a6d1249894c60eb38d3cc8ce4c1b808482b377.tar.bz2
Comparison of two class instances without __cmp__ or __rcmp__ methods
was broken.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/classobject.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 923ad45..a395801 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -523,8 +523,11 @@ instance_compare(inst, other)
object *result;
int outcome;
result = instancebinop(inst, other, "__cmp__", "__rcmp__");
- if (result == NULL)
- return -2;
+ if (result == NULL) {
+ /* no __cmp__ or __rcmp__ methods, so use addresses */
+ err_clear();
+ return inst < other ? -1 : (inst > other ? 1 : 0);
+ }
outcome = getintvalue(result);
DECREF(result);
if (outcome == -1 && err_occurred())