Commit f13adf40 authored by Guido van Rossum's avatar Guido van Rossum

Turn three recently fixed crashers into regular tests.

parent 98b09a09
# Test enhancements related to descriptors and new-style classes # Test enhancements related to descriptors and new-style classes
# XXX Please, please, please, someone convert this to unittest style!
from test.test_support import verify, vereq, verbose, TestFailed, TESTFN, get_original_stdout from test.test_support import verify, vereq, verbose, TestFailed, TESTFN, get_original_stdout
from copy import deepcopy from copy import deepcopy
import warnings import warnings
...@@ -4427,6 +4429,8 @@ def test_assign_slice(): ...@@ -4427,6 +4429,8 @@ def test_assign_slice():
# ceval.c's assign_slice used to check for # ceval.c's assign_slice used to check for
# tp->tp_as_sequence->sq_slice instead of # tp->tp_as_sequence->sq_slice instead of
# tp->tp_as_sequence->sq_ass_slice # tp->tp_as_sequence->sq_ass_slice
if verbose:
print "Testing assign_slice..."
class C(object): class C(object):
def __setslice__(self, start, stop, value): def __setslice__(self, start, stop, value):
...@@ -4436,8 +4440,70 @@ def test_assign_slice(): ...@@ -4436,8 +4440,70 @@ def test_assign_slice():
c[1:2] = 3 c[1:2] = 3
vereq(c.value, 3) vereq(c.value, 3)
def test_weakref_in_del_segfault():
# This used to segfault until r60057
if verbose:
print "Testing weakref in del segfault..."
import weakref
global ref
class Target():
def __del__(self):
global ref
ref = weakref.ref(self)
w = Target()
del w
del ref
def test_borrowed_ref_3_segfault():
# This used to segfault until r60224
if verbose:
print "Testing borrowed ref 3 segfault..."
class KeyFunc(object):
def __call__(self, n):
del d['key']
return 1
d = {'key': KeyFunc()}
try:
min(range(10), **d)
except:
pass
def test_borrowed_ref_4_segfault():
# This used to segfault until r60224
if verbose:
print "Testing borrowed ref 4 segfault..."
import types
import __builtin__
class X(object):
def __getattr__(self, name):
# this is called with name == '__bases__' by PyObject_IsInstance()
# during the unbound method call -- it frees the unbound method
# itself before it invokes its im_func.
del __builtin__.__import__
return ()
pseudoclass = X()
class Y(object):
def __call__(self, *args):
# 'self' was freed already
return (self, args)
# make an unbound method
__builtin__.__import__ = types.MethodType(Y(), None, (pseudoclass, str))
import spam
def test_main(): def test_main():
weakref_segfault() # Must be first, somehow #XXXweakref_segfault() # Must be first, somehow
wrapper_segfault() wrapper_segfault()
do_this_first() do_this_first()
class_docstrings() class_docstrings()
...@@ -4535,6 +4601,9 @@ def test_main(): ...@@ -4535,6 +4601,9 @@ def test_main():
methodwrapper() methodwrapper()
notimplemented() notimplemented()
test_assign_slice() test_assign_slice()
test_weakref_in_del_segfault()
test_borrowed_ref_3_segfault()
test_borrowed_ref_4_segfault()
if verbose: print "All OK" if verbose: print "All OK"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment