diff options
author | Brett Cannon <bcannon@gmail.com> | 2006-06-09 22:31:23 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2006-06-09 22:31:23 (GMT) |
commit | 22565aac3b75dbdf255226b217097885e59e0fcb (patch) | |
tree | 42c31b36cc7230fe703ad86356ccd9c0d66031c1 /Objects | |
parent | b2afe855e5d75a570707d6bf0e32206e4b7b1c4d (diff) | |
download | cpython-22565aac3b75dbdf255226b217097885e59e0fcb.zip cpython-22565aac3b75dbdf255226b217097885e59e0fcb.tar.gz cpython-22565aac3b75dbdf255226b217097885e59e0fcb.tar.bz2 |
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.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 83c48c2..53898c5 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, |