Commit bb3c5f74 authored by Guido van Rossum's avatar Guido van Rossum

fix comparison of instances without _-cmp__

parent f4838463
...@@ -524,14 +524,14 @@ instance_compare(inst, other) ...@@ -524,14 +524,14 @@ instance_compare(inst, other)
int outcome; int outcome;
result = instancebinop(inst, other, "__cmp__", "__rcmp__"); result = instancebinop(inst, other, "__cmp__", "__rcmp__");
if (result == NULL) { if (result == NULL) {
/* no __cmp__ or __rcmp__ methods, so use addresses */ error:
err_clear(); err_clear();
return inst < other ? -1 : (inst > other ? 1 : 0); return (inst < other) ? -1 : 1;
} }
outcome = getintvalue(result); outcome = getintvalue(result);
DECREF(result); DECREF(result);
if (outcome == -1 && err_occurred()) if (outcome == -1 && err_occurred())
return -2; goto error;
if (outcome < 0) if (outcome < 0)
return -1; return -1;
else if (outcome > 0) else if (outcome > 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment