[Python-Dev] ref leak in element tree/pyexpat (original) (raw)
Neal Norwitz nnorwitz at gmail.com
Sun Dec 18 06:49:58 CET 2005
- Previous message: [Python-Dev] [Python-checkins] commit of r41497 -python/trunk/Lib/test
- Next message: [Python-Dev] ref leak in element tree/pyexpat
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I'm not sure where the problem is, but this code leaks a reference: parser = ET.XMLParser() ; parser.feed('text')
You need this to set it up: from xmlcore.etree import cElementTree as ET
This isn't a memory leak according to valgrind.
Also, I noticed several places where errors where being ignored. What is the procedure for the element tree? Are we supposed to modify it in the python SVN or treat it as read-only?
The patch below fixes a few small problems. There were some others I noticed, but didn't add to the patch.
n
Index: Modules/_elementtree.c
--- Modules/_elementtree.c (revision 41747) +++ Modules/_elementtree.c (working copy) @@ -905,6 +905,9 @@ }
args = PyTuple_New(2);
- if (!args)
return NULL;
Py_INCREF(self); PyTuple_SET_ITEM(args, 0, (PyObject*) self); Py_INCREF(tag); PyTuple_SET_ITEM(args, 1, (PyObject*) tag);
@@ -1641,8 +1644,8 @@ PyObject* node = (PyObject*) self->last; res = PyTuple_New(2); if (res) {
Py_INCREF(action); PyTuple_SET_ITEM(res, 0, (PyObject*) action);
Py_INCREF(node); PyTuple_SET_ITEM(res, 1, (PyObject*) node);
Py_INCREF(action); PyTuple_SET_ITEM(res, 0, action);
Py_INCREF(node); PyTuple_SET_ITEM(res, 1, node); PyList_Append(self->events, res); Py_DECREF(res); } else
@@ -2586,10 +2589,14 @@ #endif
m = Py_InitModule("_elementtree", _functions);
if (!m)
return;
/* python glue code */
g = PyDict_New();
if (!g)
return;
PyDict_SetItemString(g, "builtins", PyEval_GetBuiltins());
- Previous message: [Python-Dev] [Python-checkins] commit of r41497 -python/trunk/Lib/test
- Next message: [Python-Dev] ref leak in element tree/pyexpat
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]