[Python-checkins] cpython (2.7): Issue #23783: Fixed memory leak in PyObject_ClearWeakRefs() in case of

serhiy.storchaka python-checkins at python.org
Mon Mar 30 09:01:46 CEST 2015


https://hg.python.org/cpython/rev/a8d8d16c853e
changeset: 95281:a8d8d16c853e
branch: 2.7
parent: 95278:c76a1a42799c
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Mar 30 09:53:06 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
@@ -924,11 +924,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;
 
@@ -946,8 +944,7 @@
 
 tuple = PyTuple_New(count * 2);
 if (tuple == NULL) {
- if (restore_error)
- PyErr_Fetch(&err_type, &err_value, &err_tb);
+ _PyErr_ReplaceException(err_type, err_value, err_tb);
 return;
 }
 
@@ -978,7 +975,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

AltStyle によって変換されたページ (->オリジナル) /