mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Comparison of two class instances without __cmp__ or __rcmp__ methods
was broken.
This commit is contained in:
parent
2abc49458b
commit
b9a6d12498
1 changed files with 5 additions and 2 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue