@@ -426,6 +426,13 @@ def permutations2(iterable, r=None):
426426 for proto in range (pickle .HIGHEST_PROTOCOL + 1 ):
427427 self .pickletest (proto , permutations (values , r )) # test pickling
428428
429+ @support .bigaddrspacetest
430+ def test_permutations_overflow (self ):
431+ with self .assertRaises (OverflowError ):
432+ permutations ("A" , 2 ** 30 )
433+ with self .assertRaises (OverflowError ):
434+ permutations ("A" , 2 , 2 ** 30 )
435+
429436 @support .impl_detail ("tuple reuse is specific to CPython" )
430437 def test_permutations_tuple_reuse (self ):
431438 self .assertEqual (len (set (map (id , permutations ('abcde' , 3 )))), 1 )
@@ -955,6 +962,11 @@ def product2(*args, **kwds):
955962 args = map (iter , args )
956963 self .assertEqual (len (list (product (* args ))), expected_len )
957964
965+ @support .bigaddrspacetest
966+ def test_product_overflow (self ):
967+ with self .assertRaises (OverflowError ):
968+ product (["a" ]* (2 ** 16 ), repeat = 2 ** 16 )
969+
958970 @support .impl_detail ("tuple reuse is specific to CPython" )
959971 def test_product_tuple_reuse (self ):
960972 self .assertEqual (len (set (map (id , product ('abc' , 'def' )))), 1 )
0 commit comments