@@ -418,6 +418,13 @@ def permutations2(iterable, r=None):
418418
419419 self .pickletest (permutations (values , r )) # test pickling
420420
421+ @support .bigaddrspacetest
422+ def test_permutations_overflow (self ):
423+ with self .assertRaises (OverflowError ):
424+ permutations ("A" , 2 ** 30 )
425+ with self .assertRaises (OverflowError ):
426+ permutations ("A" , 2 , 2 ** 30 )
427+
421428 @support .impl_detail ("tuple resuse is CPython specific" )
422429 def test_permutations_tuple_reuse (self ):
423430 self .assertEqual (len (set (map (id , permutations ('abcde' , 3 )))), 1 )
@@ -930,6 +937,11 @@ def product2(*args, **kwds):
930937 args = map (iter , args )
931938 self .assertEqual (len (list (product (* args ))), expected_len )
932939
940+ @support .bigaddrspacetest
941+ def test_product_overflow (self ):
942+ with self .assertRaises (OverflowError ):
943+ product (["a" ]* (2 ** 16 ), repeat = 2 ** 16 )
944+
933945 @support .impl_detail ("tuple reuse is specific to CPython" )
934946 def test_product_tuple_reuse (self ):
935947 self .assertEqual (len (set (map (id , product ('abc' , 'def' )))), 1 )
0 commit comments