[lxml-dev] Test failures on Windows
Sidnei da Silva
sidnei at awkly.org
Sat Oct 28 03:26:12 CEST 2006
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.
- 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.
By trial-and-failure, I've come up with the attached patch, which fixes
the failures on Windows. Someone more experienced should review this.
careful-not-to-hide-the-dirt-under-the-rug'ly yours,
--
Sidnei da Silva
Enfold Systems http://enfoldsystems.com
Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214
-------------- next part --------------
Index: lxml/xmlparser.pxd
===================================================================
--- lxml/xmlparser.pxd (revision 33825)
+++ lxml/xmlparser.pxd (working copy)
@@ -53,6 +53,7 @@
int recovery
int options
xmlError lastError
+ xmlParserInput* input
xmlNode* node
xmlSAXHandler* sax
@@ -127,4 +128,5 @@
char* buffer)
cdef xmlParserInput* xmlNewInputFromFile(xmlParserCtxt* ctxt,
char* filename)
+ cdef xmlParserInput* inputPop(xmlParserCtxt* ctxt)
cdef void xmlFreeInputStream(xmlParserInput* input)
Index: lxml/parser.pxi
===================================================================
--- lxml/parser.pxi (revision 33825)
+++ lxml/parser.pxi (working copy)
@@ -574,6 +574,9 @@
tree.xmlFreeDoc(ctxt.myDoc)
ctxt.myDoc = NULL
+ if ctxt.input is not NULL:
+ xmlparser.xmlFreeInputStream(xmlparser.inputPop(ctxt))
+
if result is not NULL:
if ctxt.wellFormed or recover:
__GLOBAL_PARSER_CONTEXT.initDocDict(result)
More information about the lxml-dev
mailing list