@@ -527,18 +527,16 @@ def test(f, format_spec, result):
527527 self .assertRaises (TypeError , 3.0 .__format__ , None )
528528 self .assertRaises (TypeError , 3.0 .__format__ , 0 )
529529
530- # other format specifiers shouldn't work on floats,
531- # in particular int specifiers
532- for format_spec in ([chr (x ) for x in range (ord ('a' ), ord ('z' )+ 1 )] +
533- [chr (x ) for x in range (ord ('A' ), ord ('Z' )+ 1 )]):
534- if not format_spec in 'eEfFgGn%' :
535- self .assertRaises (ValueError , format , 0.0 , format_spec )
536- self .assertRaises (ValueError , format , 1.0 , format_spec )
537- self .assertRaises (ValueError , format , - 1.0 , format_spec )
538- self .assertRaises (ValueError , format , 1e100 , format_spec )
539- self .assertRaises (ValueError , format , - 1e100 , format_spec )
540- self .assertRaises (ValueError , format , 1e-100 , format_spec )
541- self .assertRaises (ValueError , format , - 1e-100 , format_spec )
530+ # confirm format options expected to fail on floats, such as integer
531+ # presentation types
532+ for format_spec in 'sbcdoxX' :
533+ self .assertRaises (ValueError , format , 0.0 , format_spec )
534+ self .assertRaises (ValueError , format , 1.0 , format_spec )
535+ self .assertRaises (ValueError , format , - 1.0 , format_spec )
536+ self .assertRaises (ValueError , format , 1e100 , format_spec )
537+ self .assertRaises (ValueError , format , - 1e100 , format_spec )
538+ self .assertRaises (ValueError , format , 1e-100 , format_spec )
539+ self .assertRaises (ValueError , format , - 1e-100 , format_spec )
542540
543541 # Alternate float formatting
544542 test (1.0 , '.0e' , '1e+00' )
@@ -604,6 +602,12 @@ def test_slot_wrapper_types(self):
604602 self .assertIsInstance (object .__lt__ , types .WrapperDescriptorType )
605603 self .assertIsInstance (int .__lt__ , types .WrapperDescriptorType )
606604
605+ def test_dunder_get_signature (self ):
606+ sig = inspect .signature (object .__init__ .__get__ )
607+ self .assertEqual (list (sig .parameters ), ["instance" , "owner" ])
608+ # gh-93021: Second parameter is optional
609+ self .assertIs (sig .parameters ["owner" ].default , None )
610+
607611 def test_method_wrapper_types (self ):
608612 self .assertIsInstance (object ().__init__ , types .MethodWrapperType )
609613 self .assertIsInstance (object ().__str__ , types .MethodWrapperType )
@@ -629,6 +633,14 @@ def test_notimplemented_type(self):
629633 def test_none_type (self ):
630634 self .assertIsInstance (None , types .NoneType )
631635
636+ def test_traceback_and_frame_types (self ):
637+ try :
638+ raise OSError
639+ except OSError as e :
640+ exc = e
641+ self .assertIsInstance (exc .__traceback__ , types .TracebackType )
642+ self .assertIsInstance (exc .__traceback__ .tb_frame , types .FrameType )
643+
632644
633645class UnionTests (unittest .TestCase ):
634646
@@ -878,7 +890,7 @@ def test_union_parameter_substitution_errors(self):
878890 T = typing .TypeVar ("T" )
879891 x = int | T
880892 with self .assertRaises (TypeError ):
881- x [42 ]
893+ x [int , str ]
882894
883895 def test_or_type_operator_with_forward (self ):
884896 T = typing .TypeVar ('T' )
@@ -958,9 +970,9 @@ def __eq__(self, other):
958970 with self .assertRaises (ZeroDivisionError ):
959971 list [int ] | list [bt ]
960972
961- union_ga = (int | list [str ], int | collections .abc .Callable [..., str ],
962- int | d )
963- # Raise error when isinstance(type, type | genericalias )
973+ union_ga = (list [str ] | int , collections .abc .Callable [..., str ] | int ,
974+ d | int )
975+ # Raise error when isinstance(type, genericalias | type )
964976 for type_ in union_ga :
965977 with self .subTest (f"check isinstance/issubclass is invalid for { type_ } " ):
966978 with self .assertRaises (TypeError ):
0 commit comments