diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-08-05 21:26:40 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-08-05 21:26:40 (GMT) |
commit | 58720d6145eca69b9aa45b720cb3c1376b1ddaea (patch) | |
tree | 56a90729aff1127491b8f895b40b4159ca3dce56 /Objects/genobject.c | |
parent | c53204b9477a2e28b6b366fd271f61c73b805cee (diff) | |
download | cpython-58720d6145eca69b9aa45b720cb3c1376b1ddaea.zip cpython-58720d6145eca69b9aa45b720cb3c1376b1ddaea.tar.gz cpython-58720d6145eca69b9aa45b720cb3c1376b1ddaea.tar.bz2 |
Issue #17934: Add a clear() method to frame objects, to help clean up expensive details (local variables) and break reference cycles.
Diffstat (limited to 'Objects/genobject.c')
-rw-r--r-- | Objects/genobject.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index dfd90aa..08d30bf 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -15,8 +15,8 @@ gen_traverse(PyGenObject *gen, visitproc visit, void *arg) return 0; } -static void -gen_finalize(PyObject *self) +void +_PyGen_Finalize(PyObject *self) { PyGenObject *gen = (PyGenObject *)self; PyObject *res; @@ -140,6 +140,7 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc) Py_XDECREF(t); Py_XDECREF(v); Py_XDECREF(tb); + gen->gi_frame->f_gen = NULL; gen->gi_frame = NULL; Py_DECREF(f); } @@ -505,7 +506,7 @@ PyTypeObject PyGen_Type = { 0, /* tp_weaklist */ 0, /* tp_del */ 0, /* tp_version_tag */ - gen_finalize, /* tp_finalize */ + _PyGen_Finalize, /* tp_finalize */ }; PyObject * @@ -517,6 +518,7 @@ PyGen_New(PyFrameObject *f) return NULL; } gen->gi_frame = f; + f->f_gen = (PyObject *) gen; Py_INCREF(f->f_code); gen->gi_code = (PyObject *)(f->f_code); gen->gi_running = 0; |