SIGN IN SIGN UP

[3.14] gh-146480: Override the exception in _PyErr_SetKeyError() (GH-146486) (#146511)

gh-146480: Override the exception in _PyErr_SetKeyError() (GH-146486)

If _PyErr_SetKeyError() is called with an exception set, it now
replaces the current exception with KeyError (as expected), instead
of setting a SystemError or failing with a fatal error (in debug
mode).
(cherry picked from commit d4153a9f76736128306c4af01776729da846d926)

Co-authored-by: Victor Stinner <vstinner@python.org>
M
Miss Islington (bot) committed
d7e04e7b8d335542f3f9acacc3f0b8428e0916e6
Parent: cba5497
Committed by GitHub <noreply@github.com> on 3/27/2026, 11:48:29 AM