summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/crashers/infinite_rec_1.py11
-rw-r--r--Lib/test/crashers/infinite_rec_2.py10
-rw-r--r--Lib/test/crashers/infinite_rec_4.py7
-rw-r--r--Lib/test/crashers/infinite_rec_5.py10
-rw-r--r--Lib/test/test_descr.py18
5 files changed, 17 insertions, 39 deletions
diff --git a/Lib/test/crashers/infinite_rec_1.py b/Lib/test/crashers/infinite_rec_1.py
deleted file mode 100644
index 573a509b5f..0000000000
--- a/Lib/test/crashers/infinite_rec_1.py
+++ /dev/null
@@ -1,11 +0,0 @@
-
-# http://python.org/sf/1202533
-
-import new, operator
-
-class A:
- pass
-A.__mul__ = new.instancemethod(operator.mul, None, A)
-
-if __name__ == '__main__':
- A()*2 # segfault: infinite recursion in C
diff --git a/Lib/test/crashers/infinite_rec_2.py b/Lib/test/crashers/infinite_rec_2.py
deleted file mode 100644
index 5a14b33eaa..0000000000
--- a/Lib/test/crashers/infinite_rec_2.py
+++ /dev/null
@@ -1,10 +0,0 @@
-
-# http://python.org/sf/1202533
-
-class A(str):
- __get__ = getattr
-
-if __name__ == '__main__':
- a = A('a')
- A.a = a
- a.a # segfault: infinite recursion in C
diff --git a/Lib/test/crashers/infinite_rec_4.py b/Lib/test/crashers/infinite_rec_4.py
deleted file mode 100644
index 14f15208e7..0000000000
--- a/Lib/test/crashers/infinite_rec_4.py
+++ /dev/null
@@ -1,7 +0,0 @@
-
-# http://python.org/sf/1202533
-
-if __name__ == '__main__':
- lst = [apply]
- lst.append(lst)
- apply(*lst) # segfault: infinite recursion in C
diff --git a/Lib/test/crashers/infinite_rec_5.py b/Lib/test/crashers/infinite_rec_5.py
deleted file mode 100644
index 18d2963233..0000000000
--- a/Lib/test/crashers/infinite_rec_5.py
+++ /dev/null
@@ -1,10 +0,0 @@
-
-# http://python.org/sf/1267884
-
-import types
-
-class C:
- __str__ = types.InstanceType.__str__
-
-if __name__ == '__main__':
- str(C()) # segfault: infinite recursion in C
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 57cef44097..9a45cf1760 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -4,6 +4,7 @@ from test.test_support import verify, vereq, verbose, TestFailed, TESTFN, get_or
from copy import deepcopy
import warnings
import types
+import new
warnings.filterwarnings("ignore",
r'complex divmod\(\), // and % are deprecated$',
@@ -1981,6 +1982,10 @@ def specials():
unsafecmp(1, 1L)
unsafecmp(1L, 1)
+def recursions():
+ if verbose:
+ print "Testing recursion checks ..."
+
class Letter(str):
def __new__(cls, letter):
if letter == 'EPS':
@@ -1990,7 +1995,6 @@ def specials():
if not self:
return 'EPS'
return self
-
# sys.stdout needs to be the original to trigger the recursion bug
import sys
test_stdout = sys.stdout
@@ -2004,6 +2008,17 @@ def specials():
raise TestFailed, "expected a RuntimeError for print recursion"
sys.stdout = test_stdout
+ # Bug #1202533.
+ class A(object):
+ pass
+ A.__mul__ = new.instancemethod(lambda self, x: self * x, None, A)
+ try:
+ A()*2
+ except RuntimeError:
+ pass
+ else:
+ raise TestFailed("expected a RuntimeError")
+
def weakrefs():
if verbose: print "Testing weak references..."
import weakref
@@ -4395,6 +4410,7 @@ def test_main():
overloading()
methods()
specials()
+ recursions()
weakrefs()
properties()
supers()