summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2006-06-13 21:46:41 (GMT)
committerBrett Cannon <bcannon@gmail.com>2006-06-13 21:46:41 (GMT)
commitea3912b0da71e16b8a37e04fcf3969dc85c27fa1 (patch)
treec620923df225897ffdd560e09ecd99efd692c586 /Objects
parent64116f931cbc517f16f3557c2c776b0f835b6384 (diff)
downloadcpython-ea3912b0da71e16b8a37e04fcf3969dc85c27fa1.zip
cpython-ea3912b0da71e16b8a37e04fcf3969dc85c27fa1.tar.gz
cpython-ea3912b0da71e16b8a37e04fcf3969dc85c27fa1.tar.bz2
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 .
Diffstat (limited to 'Objects')
-rw-r--r--Objects/classobject.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 9e57269..c69ba74 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -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;