mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
gh-97591: In Exception.__setstate__()
acquire strong references before calling tp_hash
slot (GH-97700)
(cherry picked from commit d639438609
)
Co-authored-by: Ofey Chan <ofey206@gmail.com>
This commit is contained in:
parent
9189cd6b05
commit
dbde686a49
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