[Python-Dev] ref leak in element tree/pyexpat
Fredrik Lundh
fredrik at pythonware.com
Sun Dec 18 14:51:05 CET 2005
Neal Norwitz wrote:
> I'm not sure where the problem is, but this code leaks a reference:
> parser = ET.XMLParser() ; parser.feed('<x>text</x>')
>
> You need this to set it up:
> from xmlcore.etree import cElementTree as ET
>
> This isn't a memory leak according to valgrind.
looks like it's stealing more None references than it should. here's a more
isolated test case:
tree = ET.TreeBuilder()
tree.start("x")
tree.data("text")
tree.end("x")
if you remove *either* the data or the end call, the leak goes away. I'll
take a look.
> 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 overall goal is to be able to say that Python X.Y.Z ships with Element-
Tree A.B.C. to achieve this, the Python SVN should be treated as mostly
read-only -- with the exception of critical errors (crashes seen in the wild,
serious leaks, security issues, etc) and build/portability issues.
> The patch below fixes a few small problems. There were some others I
> noticed, but didn't add to the patch.
thanks. I'll fix these (and a few others) in the next "official" release.
</F>
More information about the Python-Dev
mailing list