changeset: 81446:848738d3c40f parent: 81444:30eb98c8afef parent: 81445:5b36768b9a11 user: Eli Bendersky date: Sat Jan 12 05:21:06 2013 -0800 description: Close #16076: fix refleak in pickling of Element. Thanks to Ezio Melotti and Daniel Shahaf for the patch. diff -r 30eb98c8afef -r 848738d3c40f Modules/_elementtree.c --- a/Modules/_elementtree.c Sat Jan 12 12:31:00 2013 +0100 +++ b/Modules/_elementtree.c Sat Jan 12 05:21:06 2013 -0800 @@ -859,8 +859,10 @@ PICKLED_ATTRIB, self->extra->attrib, PICKLED_TEXT, self->text, PICKLED_TAIL, self->tail); - if (instancedict) + if (instancedict) { + Py_DECREF(children); return instancedict; + } else { for (i = 0; i < PyList_GET_SIZE(children); i++) Py_DECREF(PyList_GET_ITEM(children, i)); @@ -884,25 +886,17 @@ PyErr_SetString(PyExc_TypeError, "tag may not be NULL"); return NULL; } - if (!text) { - Py_INCREF(Py_None); - text = Py_None; - } - if (!tail) { - Py_INCREF(Py_None); - tail = Py_None; - } Py_CLEAR(self->tag); self->tag = tag; Py_INCREF(self->tag); Py_CLEAR(self->text); - self->text = text; + self->text = text ? text : Py_None; Py_INCREF(self->text); Py_CLEAR(self->tail); - self->tail = tail; + self->tail = tail ? tail : Py_None; Py_INCREF(self->tail); /* Handle ATTRIB and CHILDREN. */

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