mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
An object with __call__ as an attribute, when called, will have that attribute checked for __call__ itself, and will continue to look until it finds an object without the attribute. This can lead to an infinite recursion.
Closes bug #532646, again. Will be backported.
This commit is contained in:
parent
b2afe855e5
commit
22565aac3b
4 changed files with 30 additions and 9 deletions
|
@ -1790,7 +1790,15 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
|
|||
ternaryfunc call;
|
||||
|
||||
if ((call = func->ob_type->tp_call) != NULL) {
|
||||
/* slot_tp_call() will be called and ends up calling
|
||||
PyObject_Call() if the object returned for __call__ has
|
||||
__call__ itself defined upon it. This can be an infinite
|
||||
recursion if you set __call__ in a class to an instance of
|
||||
it. */
|
||||
if (Py_EnterRecursiveCall(" in __call__"))
|
||||
return NULL;
|
||||
PyObject *result = (*call)(func, arg, kw);
|
||||
Py_LeaveRecursiveCall();
|
||||
if (result == NULL && !PyErr_Occurred())
|
||||
PyErr_SetString(
|
||||
PyExc_SystemError,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue