gh-145876: Do not mask KeyErrors raised during dictionary unpacking in call (GH-146472)

KeyErrors raised in keys() or __getitem__() during dictionary unpacking
in call (func(**mymapping)) are no longer masked by TypeError.
This commit is contained in:
Serhiy Storchaka 2026-03-29 11:58:52 +03:00 committed by GitHub
parent 1af025dd22
commit 6932c3ee6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 71 additions and 73 deletions

View file

@ -2416,10 +2416,12 @@ dummy_func(
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
PyObject *dict_o = PyStackRef_AsPyObjectBorrow(dict);
PyObject *update_o = PyStackRef_AsPyObjectBorrow(update);
PyObject *dupkey = NULL;
int err = _PyDict_MergeEx(dict_o, update_o, 2);
int err = _PyDict_MergeUniq(dict_o, update_o, &dupkey);
if (err < 0) {
_PyEval_FormatKwargsError(tstate, callable_o, update_o);
_PyEval_FormatKwargsError(tstate, callable_o, update_o, dupkey);
Py_XDECREF(dupkey);
ERROR_NO_POP();
}
u = update;