@@ -3154,6 +3154,10 @@ def test_posonly_vararg(self):
31543154 self .assertEqual (ac_tester .posonly_vararg (1 , 2 ), (1 , 2 , ()))
31553155 self .assertEqual (ac_tester .posonly_vararg (1 , b = 2 ), (1 , 2 , ()))
31563156 self .assertEqual (ac_tester .posonly_vararg (1 , 2 , 3 , 4 ), (1 , 2 , (3 , 4 )))
3157+ with self .assertRaises (TypeError ):
3158+ ac_tester .posonly_vararg (b = 4 )
3159+ with self .assertRaises (TypeError ):
3160+ ac_tester .posonly_vararg (1 , 2 , 3 , b = 4 )
31573161
31583162 def test_vararg_and_posonly (self ):
31593163 with self .assertRaises (TypeError ):
@@ -3204,6 +3208,37 @@ def test_gh_99240_double_free(self):
32043208 with self .assertRaisesRegex (TypeError , err ):
32053209 ac_tester .gh_99240_double_free ('a' , '\0 b' )
32063210
3211+ def test_null_or_tuple_for_varargs (self ):
3212+ # All of these should not crash:
3213+ valid_args_for_test = [
3214+ (('a' ,), {},
3215+ ('a' , (), False )),
3216+ (('a' , 1 , 2 , 3 ), {'covariant' : True },
3217+ ('a' , (1 , 2 , 3 ), True )),
3218+ ((), {'name' : 'a' },
3219+ ('a' , (), False )),
3220+ ((), {'name' : 'a' , 'covariant' : True },
3221+ ('a' , (), True )),
3222+ ((), {'covariant' : True , 'name' : 'a' },
3223+ ('a' , (), True )),
3224+ ]
3225+ for args , kwargs , expected in valid_args_for_test :
3226+ with self .subTest (args = args , kwargs = kwargs ):
3227+ self .assertEqual (
3228+ ac_tester .null_or_tuple_for_varargs (* args , ** kwargs ),
3229+ expected ,
3230+ )
3231+
3232+ def test_null_or_tuple_for_varargs_error (self ):
3233+ with self .assertRaises (TypeError ):
3234+ ac_tester .null_or_tuple_for_varargs (covariant = True )
3235+ with self .assertRaises (TypeError ):
3236+ ac_tester .null_or_tuple_for_varargs (1 , name = 'a' )
3237+ with self .assertRaises (TypeError ):
3238+ ac_tester .null_or_tuple_for_varargs (1 , 2 , 3 , name = 'a' , covariant = True )
3239+ with self .assertRaises (TypeError ):
3240+ ac_tester .null_or_tuple_for_varargs (1 , 2 , 3 , covariant = True , name = 'a' )
3241+
32073242 def test_cloned_func_exception_message (self ):
32083243 incorrect_arg = - 1 # f1() and f2() accept a single str
32093244 with self .assertRaisesRegex (TypeError , "clone_f1" ):
0 commit comments