]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Classic class that defined ``def __coerce__(self, other): return other, self``
authorBrett Cannon <bcannon@gmail.com>
Tue, 13 Jun 2006 21:50:24 +0000 (21:50 +0000)
committerBrett Cannon <bcannon@gmail.com>
Tue, 13 Jun 2006 21:50:24 +0000 (21:50 +0000)
would infinitely recourse and segfault the interpreter.  Now a recursion check
occurs after a coercion.

Backport of fix for bug #992017.

Misc/NEWS
Objects/classobject.c

index f83d112fe62b4ea82dab64159c9a5d3220e1ecfb..005255fdaa7c81bb1da8ee79ceff146c53d33f51 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.4.4c1?
 Core and builtins
 -----------------
 
+- Bug #992017: A classic class that defined a __coerce__() method that returned
+  its arguments swapped would infinitely recurse and segfault the interpreter.
+
 - Bug #532646: The object set to the __call__ attribute has its own __call__
   attribute checked; this continues until the attribute can no longer be found
   or segfaulting.  Recursion limit is now followed.
index 187f8d0648c12b77e896f9971bf1721da5e287d9..bbd4c6d8f53c9f6206167ecf791aa693557bcacf 100644 (file)
@@ -1428,10 +1428,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;