File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -931,11 +931,19 @@ def test_tp_bases_slot_none(self):
931931 def test__pyerr_setkeyerror (self ):
932932 # Test _PyErr_SetKeyError()
933933 _pyerr_setkeyerror = _testinternalcapi ._pyerr_setkeyerror
934- with self .assertRaises (KeyError ) as cm :
935- # Test _PyErr_SetKeyError() with an exception set to check
936- # that the function overrides the current exception
937- _pyerr_setkeyerror ("key" )
938- self .assertEqual (cm .exception .args , ("key" ,))
934+ for arg in (
935+ "key" ,
936+ # check that a tuple argument is not unpacked
937+ (1 , 2 , 3 ),
938+ KeyError ('arg' ),
939+ ):
940+ with self .subTest (arg = arg ):
941+ with self .assertRaises (KeyError ) as cm :
942+ # Test calling _PyErr_SetKeyError() with an exception set
943+ # to check that the function overrides the current
944+ # exception.
945+ _pyerr_setkeyerror (arg )
946+ self .assertEqual (cm .exception .args , (arg ,))
939947
940948
941949@requires_limited_api
Original file line number Diff line number Diff line change @@ -246,9 +246,7 @@ PyErr_SetObject(PyObject *exception, PyObject *value)
246246 _PyErr_SetObject (tstate , exception , value );
247247}
248248
249- /* Set a key error with the specified argument, wrapping it in a
250- * tuple automatically so that tuple keys are not unpacked as the
251- * exception arguments.
249+ /* Set a key error with the specified argument.
252250 *
253251 * If an exception is already set, override the exception. */
254252void
You can’t perform that action at this time.
0 commit comments