File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -450,6 +450,20 @@ def test_iterator_unpickle_compat(self):
450
450
it = pickle .loads (t )
451
451
self .assertEqual (list (it ), [14 , 16 , 18 ])
452
452
453
+ def test_iterator_setstate (self ):
454
+ it = iter (range (10 , 20 , 2 ))
455
+ it .__setstate__ (2 )
456
+ self .assertEqual (list (it ), [14 , 16 , 18 ])
457
+ it = reversed (range (10 , 20 , 2 ))
458
+ it .__setstate__ (3 )
459
+ self .assertEqual (list (it ), [12 , 10 ])
460
+ it = iter (range (- 2 ** 65 , 20 , 2 ))
461
+ it .__setstate__ (2 ** 64 + 7 )
462
+ self .assertEqual (list (it ), [14 , 16 , 18 ])
463
+ it = reversed (range (10 , 2 ** 65 , 2 ))
464
+ it .__setstate__ (2 ** 64 - 7 )
465
+ self .assertEqual (list (it ), [12 , 10 ])
466
+
453
467
def test_odd_bug (self ):
454
468
# This used to raise a "SystemError: NULL result without error"
455
469
# because the range validation step was eating the exception
You can’t perform that action at this time.
0 commit comments