summaryrefslogtreecommitdiff
path: root/Objects/abstract.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 83c48c21cb..53898c5990 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -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,