summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2006-06-09 22:31:23 (GMT)
committerBrett Cannon <bcannon@gmail.com>2006-06-09 22:31:23 (GMT)
commit22565aac3b75dbdf255226b217097885e59e0fcb (patch)
tree42c31b36cc7230fe703ad86356ccd9c0d66031c1 /Lib/test
parentb2afe855e5d75a570707d6bf0e32206e4b7b1c4d (diff)
downloadcpython-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 'Lib/test')
-rw-r--r--Lib/test/crashers/infinite_rec_3.py9
-rw-r--r--Lib/test/test_descr.py16
2 files changed, 16 insertions, 9 deletions
diff --git a/Lib/test/crashers/infinite_rec_3.py b/Lib/test/crashers/infinite_rec_3.py
deleted file mode 100644
index 0b04e4c..0000000
--- a/Lib/test/crashers/infinite_rec_3.py
+++ /dev/null
@@ -1,9 +0,0 @@
-
-# http://python.org/sf/1202533
-
-class A(object):
- pass
-A.__call__ = A()
-
-if __name__ == '__main__':
- A()() # segfault: infinite recursion in C
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 @@ def kwdargs():
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 @@ def test_main():
buffer_inherit()
str_of_str_subclass()
kwdargs()
+ recursive__call__()
delhook()
hashinherit()
strops()