diff Objects/typeobject.c @ 38905:3cdde45a468d 2.4

Backport of r47061.
author Armin Rigo <arigo@tunes.org>
date Wed, 21 Jun 2006 22:11:16 +0000
parents e43d5d2ca50a
children 8296fb96cc18
line wrap: on
line diff
--- a/Objects/typeobject.c	Sun Jun 18 02:58:20 2006 +0000
+++ b/Objects/typeobject.c	Wed Jun 21 22:11:16 2006 +0000
@@ -4530,7 +4530,16 @@
 
 	if (meth == NULL)
 		return NULL;
+
+	/* PyObject_Call() will end up calling slot_tp_call() again 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;
 	res = PyObject_Call(meth, args, kwds);
+	Py_LeaveRecursiveCall();
+
 	Py_DECREF(meth);
 	return res;
 }