[lxml-dev] Test failures on Windows
Stefan Behnel
behnel_ml at gkec.informatik.tu-darmstadt.de
Sat Oct 28 10:05:14 CEST 2006
Hi Sidnei,
Sidnei da Silva wrote:
> On Fri, Oct 27, 2006 at 10:55:11PM +0200, Stefan Behnel wrote:
> | Thanks. Most of those are the usual Windows bugs that you can't delete an open
> | file. I fixed some and just silenced the remaining two - shouldn't be too much
> | of a problem if tiny temporary files are not deleted after running the test
> | cases (which is a rare enough event anyway...)
>
> Two issues here:
>
> - In Python2.4 it raises OSError instead of WindowsError. I guess
> that is one of the changes in Python2.5.
Good to know.
> - I believe that this might be a real bug that needs fixing.
>
> Why it might be a bug:
>
> - I looked at the source in lxml and I see that this ends up calling
> xmlparser.xmlCtxtReadFile, which just delegates down to
> libxml2. Well, somewhere in there it seems like the file is read
> but not closed.
You got me convinced. I think that's because we are using the context reusing
calls (xmlCtxt*). They require calling xmlCtxtReset afterwards to clean up
both the input stack and memory resources. This is normally called
automatically when using the parser context the next time (which is why there
never were any enduring side effects), but waiting for that has the temporal
side effect of leaving the input stream open when passing control back to the
user code.
Now, the problem is, running xmlCtxtReset can currently segfault in some
cases, so we can't just call it carelessly. I played with it a bit to figure
out in which cases it can be called, but it doesn't look like we can safely
call it in every case where it would make sense. Guess I'll file a bug report
on it and try to come up with a work-around...
Stefan
More information about the lxml-dev
mailing list