Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2484aae

Browse files
committed
Added a test that provokes the hypothesized (in my last checkin comment)
debug-build failure when an instance of a new-style class is resurrected by a __del__ method -- we simply never had any code that tried this. This is already fixed in 2.3 CVS. In 2.2.1, it blows up via Fatal Python error: GC object already in linked list I'll fix it in 2.2.1 CVS next.
1 parent 3459251 commit 2484aae

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lib/test/test_descr.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3183,6 +3183,25 @@ def __getitem__(self, x):
31833183
a.__setitem__(slice(0, 2, 1), [2,3])
31843184
vereq(a, [2,3,1])
31853185

3186+
def subtype_resurrection():
3187+
if verbose:
3188+
print "Testing resurrection of new-style instance."
3189+
3190+
class C(object):
3191+
container = []
3192+
3193+
def __del__(self):
3194+
# resurrect the instance
3195+
C.container.append(self)
3196+
3197+
c = C()
3198+
c.attr = 42
3199+
# The only interesting thing here is whether this blows up in a
3200+
# debug build, due to flawed GC tracking logic in typeobject.c's
3201+
# call_finalizer() (a 2.2.1 bug).
3202+
del c
3203+
del C.container[-1] # resurrect it again for the heck of it
3204+
vereq(C.container[-1].attr, 42)
31863205

31873206
def do_this_first():
31883207
if verbose:
@@ -3274,6 +3293,7 @@ def test_main():
32743293
string_exceptions()
32753294
copy_setstate()
32763295
slices()
3296+
subtype_resurrection()
32773297
if verbose: print "All OK"
32783298

32793299
if __name__ == "__main__":

0 commit comments

Comments
 (0)