@@ -4997,7 +4997,7 @@ def test_pickle(self):
49974997 P = ParamSpec ('P' )
49984998 P_co = ParamSpec ('P_co' , covariant = True )
49994999 P_contra = ParamSpec ('P_contra' , contravariant = True )
5000- P_default = ParamSpec ('P_default' , default = int )
5000+ P_default = ParamSpec ('P_default' , default = [ int ] )
50015001 for proto in range (pickle .HIGHEST_PROTOCOL ):
50025002 with self .subTest (f'Pickle protocol { proto } ' ):
50035003 for paramspec in (P , P_co , P_contra , P_default ):
@@ -6363,8 +6363,8 @@ def test_typevar_none(self):
63636363 self .assertTrue (U_None .has_default ())
63646364
63656365 def test_paramspec (self ):
6366- P = ParamSpec ('P' , default = ( str , int ) )
6367- self .assertEqual (P .__default__ , ( str , int ) )
6366+ P = ParamSpec ('P' , default = [ str , int ] )
6367+ self .assertEqual (P .__default__ , [ str , int ] )
63686368 self .assertTrue (P .has_default ())
63696369 self .assertIsInstance (P , ParamSpec )
63706370 if hasattr (typing , "ParamSpec" ):
@@ -6457,6 +6457,17 @@ def test_pickle(self):
64576457 self .assertEqual (z .__bound__ , typevar .__bound__ )
64586458 self .assertEqual (z .__default__ , typevar .__default__ )
64596459
6460+ def test_strange_defaults_are_allowed (self ):
6461+ # Leave it to type checkers to check whether strange default values
6462+ # should be allowed or disallowed
6463+ def not_a_type (): ...
6464+
6465+ for typevarlike_cls in TypeVar , ParamSpec , TypeVarTuple :
6466+ for default in not_a_type , 42 , bytearray (), (int , not_a_type , 42 ):
6467+ with self .subTest (typevarlike_cls = typevarlike_cls , default = default ):
6468+ T = typevarlike_cls ("T" , default = default )
6469+ self .assertEqual (T .__default__ , default )
6470+
64606471 @skip_if_py313_beta_1
64616472 def test_allow_default_after_non_default_in_alias (self ):
64626473 T_default = TypeVar ('T_default' , default = int )
0 commit comments