Skip to content

Commit 8fad5a4

Browse files
committed
Redo test
1 parent 0d8974e commit 8fad5a4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Lib/test/test_tuple.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -421,22 +421,23 @@ def test_bug_59313(self):
421421
# would create incomplete tuples which were visible
422422
# to the cycle GC
423423
TAG = object()
424+
tuples = []
424425

425-
def monitor():
426-
lst = [x for x in gc.get_referrers(TAG)
426+
def referrer_tuples():
427+
return [x for x in gc.get_referrers(TAG)
427428
if isinstance(x, tuple)]
428-
t = lst[0] # this *is* the result tuple
429-
print(t) # full of nulls !
430-
return t # Keep it alive for some time
431429

432430
def my_iter():
431+
nonlocal tuples
433432
yield TAG # 'tag' gets stored in the result tuple
434-
t = monitor()
433+
tuples += referrer_tuples()
435434
for x in range(10):
436-
yield x # SystemError when the tuple needs to be resized
435+
tuples += referrer_tuples()
436+
# Prior to 3.13 would raise a SystemError when the tuple needs to be resized
437+
yield x
437438

438-
with self.assertRaises(IndexError):
439-
tuple(my_iter())
439+
self.assertEqual(tuple(my_iter()), (TAG, *range(10)))
440+
self.assertEqual(tuples, [])
440441

441442
# Notes on testing hash codes. The primary thing is that Python doesn't
442443
# care about "random" hash codes. To the contrary, we like them to be

0 commit comments

Comments
 (0)