https://github.com/python/cpython/commit/b3b7c0025be4f9d08d5f4259b8ffc7b05fa0ba7f
commit: b3b7c0025be4f9d08d5f4259b8ffc7b05fa0ba7f
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-06-15T11:46:52+02:00
summary:
gh-146102: Don't clear exception on success in odictobject.c (#151347)
Calling PyErr_Clear() on success can mask a pending exception.
Replace it with an assertion checking that no exception is set.
files:
M Objects/odictobject.c
diff --git a/Objects/odictobject.c b/Objects/odictobject.c
index 6f05395b18d781..14c1b02405822c 100644
--- a/Objects/odictobject.c
+++ b/Objects/odictobject.c
@@ -2206,13 +2206,14 @@ update __setitem__
static int
mutablemapping_add_pairs(PyObject *self, PyObject *pairs)
{
+ assert(!PyErr_Occurred());
+
PyObject *pair, *iterator, *unexpected;
int res = 0;
iterator = PyObject_GetIter(pairs);
if (iterator == NULL)
return -1;
- PyErr_Clear();
while ((pair = PyIter_Next(iterator)) != NULL) {
/* could be more efficient (see UNPACK_SEQUENCE in ceval.c) */
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]