[Python-checkins] cpython (merge 3.4 -> default): Issue #23783: Fixed memory leak in PyObject_ClearWeakRefs() in case of
serhiy.storchaka
python-checkins at python.org
Mon Mar 30 09:01:44 CEST 2015
https://hg.python.org/cpython/rev/6a4b83c56b86
changeset: 95280:6a4b83c56b86
parent: 95276:cb96fd376baa
parent: 95279:74d766d819a6
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Mar 30 09:52:53 2015 +0300
summary:
Issue #23783: Fixed memory leak in PyObject_ClearWeakRefs() in case of
MemoryError.
files:
Objects/weakrefobject.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -900,11 +900,9 @@
if (*list != NULL) {
PyWeakReference *current = *list;
Py_ssize_t count = _PyWeakref_GetWeakrefCount(current);
- int restore_error = PyErr_Occurred() ? 1 : 0;
PyObject *err_type, *err_value, *err_tb;
- if (restore_error)
- PyErr_Fetch(&err_type, &err_value, &err_tb);
+ PyErr_Fetch(&err_type, &err_value, &err_tb);
if (count == 1) {
PyObject *callback = current->wr_callback;
@@ -922,8 +920,7 @@
tuple = PyTuple_New(count * 2);
if (tuple == NULL) {
- if (restore_error)
- PyErr_Fetch(&err_type, &err_value, &err_tb);
+ _PyErr_ChainExceptions(err_type, err_value, err_tb);
return;
}
@@ -954,7 +951,7 @@
}
Py_DECREF(tuple);
}
- if (restore_error)
- PyErr_Restore(err_type, err_value, err_tb);
+ assert(!PyErr_Occurred());
+ PyErr_Restore(err_type, err_value, err_tb);
}
}
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list