summaryrefslogtreecommitdiffstats
path: root/Objects/weakrefobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/weakrefobject.c')
-rw-r--r--Objects/weakrefobject.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index bd7720e..5a3e49a 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -959,9 +959,8 @@ PyObject_ClearWeakRefs(PyObject *object)
if (*list != NULL) {
PyWeakReference *current = *list;
Py_ssize_t count = _PyWeakref_GetWeakrefCount(current);
- PyObject *err_type, *err_value, *err_tb;
+ PyObject *exc = PyErr_GetRaisedException();
- PyErr_Fetch(&err_type, &err_value, &err_tb);
if (count == 1) {
PyObject *callback = current->wr_callback;
@@ -980,7 +979,7 @@ PyObject_ClearWeakRefs(PyObject *object)
tuple = PyTuple_New(count * 2);
if (tuple == NULL) {
- _PyErr_ChainExceptions(err_type, err_value, err_tb);
+ _PyErr_ChainExceptions1(exc);
return;
}
@@ -1010,7 +1009,7 @@ PyObject_ClearWeakRefs(PyObject *object)
Py_DECREF(tuple);
}
assert(!PyErr_Occurred());
- PyErr_Restore(err_type, err_value, err_tb);
+ PyErr_SetRaisedException(exc);
}
}