Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb3c5f7

Browse files
committed
fix comparison of instances without _-cmp__
1 parent f483846 commit bb3c5f7

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Objects/classobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,14 @@ instance_compare(inst, other)
524524
int outcome;
525525
result = instancebinop(inst, other, "__cmp__", "__rcmp__");
526526
if (result == NULL) {
527-
/* no __cmp__ or __rcmp__ methods, so use addresses */
527+
error:
528528
err_clear();
529-
return inst < other ? -1 : (inst > other ? 1 : 0);
529+
return (inst < other) ? -1 : 1;
530530
}
531531
outcome = getintvalue(result);
532532
DECREF(result);
533533
if (outcome == -1 && err_occurred())
534-
return -2;
534+
goto error;
535535
if (outcome < 0)
536536
return -1;
537537
else if (outcome > 0)

0 commit comments

Comments
 (0)