If a classic class defined a __coerce__() method that just returned its two

arguments in reverse, the interpreter would infinitely recourse trying to get a
coercion that worked.  So put in a recursion check after a coercion is made and
the next call to attempt to use the coerced values.

Fixes bug #992017 and closes crashers/coerce.py .
This commit is contained in:
Brett Cannon 2006-06-13 21:46:41 +00:00
parent 64116f931c
commit ea3912b0da
3 changed files with 6 additions and 9 deletions

View file

@ -1368,10 +1368,13 @@ half_binop(PyObject *v, PyObject *w, char *opname, binaryfunc thisfunc,
* argument */
result = generic_binary_op(v1, w, opname);
} else {
if (Py_EnterRecursiveCall(" after coercion"))
return NULL;
if (swapped)
result = (thisfunc)(w, v1);
else
result = (thisfunc)(v1, w);
Py_LeaveRecursiveCall();
}
Py_DECREF(coerced);
return result;