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.
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index ca91042..d9249b6 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -3171,6 +3171,21 @@
list.__init__(a, sequence=[0, 1, 2])
vereq(a, [0, 1, 2])
+def recursive__call__():
+ if verbose: print ("Testing recursive __call__() by setting to instance of "
+ "class ...")
+ class A(object):
+ pass
+
+ A.__call__ = A()
+ try:
+ A()()
+ except RuntimeError:
+ pass
+ else:
+ raise TestFailed("Recursion limit should have been reached for "
+ "__call__()")
+
def delhook():
if verbose: print "Testing __del__ hook..."
log = []
@@ -4164,6 +4179,7 @@
buffer_inherit()
str_of_str_subclass()
kwdargs()
+ recursive__call__()
delhook()
hashinherit()
strops()