@@ -4997,7 +4997,7 @@ def test_pickle(self):
4997
4997
P = ParamSpec ('P' )
4998
4998
P_co = ParamSpec ('P_co' , covariant = True )
4999
4999
P_contra = ParamSpec ('P_contra' , contravariant = True )
5000
- P_default = ParamSpec ('P_default' , default = int )
5000
+ P_default = ParamSpec ('P_default' , default = [ int ] )
5001
5001
for proto in range (pickle .HIGHEST_PROTOCOL ):
5002
5002
with self .subTest (f'Pickle protocol { proto } ' ):
5003
5003
for paramspec in (P , P_co , P_contra , P_default ):
@@ -6363,8 +6363,8 @@ def test_typevar_none(self):
6363
6363
self .assertTrue (U_None .has_default ())
6364
6364
6365
6365
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 ] )
6368
6368
self .assertTrue (P .has_default ())
6369
6369
self .assertIsInstance (P , ParamSpec )
6370
6370
if hasattr (typing , "ParamSpec" ):
@@ -6457,6 +6457,17 @@ def test_pickle(self):
6457
6457
self .assertEqual (z .__bound__ , typevar .__bound__ )
6458
6458
self .assertEqual (z .__default__ , typevar .__default__ )
6459
6459
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
+
6460
6471
@skip_if_py313_beta_1
6461
6472
def test_allow_default_after_non_default_in_alias (self ):
6462
6473
T_default = TypeVar ('T_default' , default = int )
0 commit comments