mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
gh-97591: In Exception.__setstate__()
acquire strong references before calling tp_hash
slot (#97700)
This commit is contained in:
parent
8baef8ae36
commit
d639438609
3 changed files with 34 additions and 1 deletions
|
@ -167,8 +167,14 @@ BaseException_setstate(PyObject *self, PyObject *state)
|
|||
return NULL;
|
||||
}
|
||||
while (PyDict_Next(state, &i, &d_key, &d_value)) {
|
||||
if (PyObject_SetAttr(self, d_key, d_value) < 0)
|
||||
Py_INCREF(d_key);
|
||||
Py_INCREF(d_value);
|
||||
int res = PyObject_SetAttr(self, d_key, d_value);
|
||||
Py_DECREF(d_value);
|
||||
Py_DECREF(d_key);
|
||||
if (res < 0) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue