File tree 1 file changed +10
-9
lines changed
1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -421,22 +421,23 @@ def test_bug_59313(self):
421
421
# would create incomplete tuples which were visible
422
422
# to the cycle GC
423
423
TAG = object ()
424
+ tuples = []
424
425
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 )
427
428
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
431
429
432
430
def my_iter ():
431
+ nonlocal tuples
433
432
yield TAG # 'tag' gets stored in the result tuple
434
- t = monitor ()
433
+ tuples += referrer_tuples ()
435
434
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
437
438
438
- with self .assertRaises ( IndexError ):
439
- tuple ( my_iter () )
439
+ self .assertEqual ( tuple ( my_iter ()), ( TAG , * range ( 10 )))
440
+ self . assertEqual ( tuples , [] )
440
441
441
442
# Notes on testing hash codes. The primary thing is that Python doesn't
442
443
# care about "random" hash codes. To the contrary, we like them to be
You can’t perform that action at this time.
0 commit comments