diff options
-rw-r--r-- | Lib/test/crashers/coerce.py | 9 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Objects/classobject.c | 3 |
3 files changed, 6 insertions, 9 deletions
diff --git a/Lib/test/crashers/coerce.py b/Lib/test/crashers/coerce.py deleted file mode 100644 index 574956b..0000000 --- a/Lib/test/crashers/coerce.py +++ /dev/null @@ -1,9 +0,0 @@ - -# http://python.org/sf/992017 - -class foo: - def __coerce__(self, other): - return other, self - -if __name__ == '__main__': - foo()+1 # segfault: infinite recursion in C @@ -12,6 +12,9 @@ What's New in Python 2.5 beta 1? 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. + - Fix the socket tests so they can be run concurrently. - Removed 5 integers from C frame objects (PyFrameObject). 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; |