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

Skip to content

Commit 82fc51c

Browse files
committed
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.)
1 parent 49b253b commit 82fc51c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Objects/object.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,11 @@ do_cmp(PyObject *v, PyObject *w)
580580
cmpfunc f;
581581

582582
if (v->ob_type == w->ob_type
583-
&& (f = v->ob_type->tp_compare) != NULL)
584-
return (*f)(v, w);
583+
&& (f = v->ob_type->tp_compare) != NULL) {
584+
c = (*f)(v, w);
585+
if (c != 2 || !PyInstance_Check(v))
586+
return c;
587+
}
585588
c = try_rich_to_3way_compare(v, w);
586589
if (c < 2)
587590
return c;

0 commit comments

Comments
 (0)