mirror of
https://github.com/python/cpython.git
synced 2025-07-29 22:24:49 +00:00
Issue #24726: Revert setting the value on the dict if
_odict_add_new_node() fails.
This commit is contained in:
commit
3a811f272a
1 changed files with 7 additions and 1 deletions
|
@ -1721,7 +1721,13 @@ PyODict_SetItem(PyObject *od, PyObject *key, PyObject *value) {
|
||||||
int res = PyDict_SetItem(od, key, value);
|
int res = PyDict_SetItem(od, key, value);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
res = _odict_add_new_node((PyODictObject *)od, key);
|
res = _odict_add_new_node((PyODictObject *)od, key);
|
||||||
/* XXX Revert setting the value on the dict? */
|
if (res < 0) {
|
||||||
|
/* Revert setting the value on the dict */
|
||||||
|
PyObject *exc, *val, *tb;
|
||||||
|
PyErr_Fetch(&exc, &val, &tb);
|
||||||
|
(void) PyDict_DelItem(od, key);
|
||||||
|
_PyErr_ChainExceptions(exc, val, tb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue