Skip to content

Commit 29ab5d8

Browse files
committed
gh-146102: Don't clear exception on success in odictobject.c
Calling PyErr_Clear() on success can mask a pending exception. Replace it with an assertion checking that no exception is set.
1 parent 72e7edd commit 29ab5d8

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Objects/odictobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2206,13 +2206,14 @@ update __setitem__
22062206
static int
22072207
mutablemapping_add_pairs(PyObject *self, PyObject *pairs)
22082208
{
2209+
assert(!PyErr_Occurred());
2210+
22092211
PyObject *pair, *iterator, *unexpected;
22102212
int res = 0;
22112213

22122214
iterator = PyObject_GetIter(pairs);
22132215
if (iterator == NULL)
22142216
return -1;
2215-
PyErr_Clear();
22162217

22172218
while ((pair = PyIter_Next(iterator)) != NULL) {
22182219
/* could be more efficient (see UNPACK_SEQUENCE in ceval.c) */

0 commit comments

Comments
 (0)