RE: [xml] Python bindings: per parser context error handlers

  Actually, the more I look at it the less I agree with the code.
libxml_xmlParserCtxtPtrWrap() allocate an empty xmlParserCtxtPyCtxt
each time the parser context reference is passed back to the Python
level. Plus it doesn't not even check if ctxt->_private existed or
not. I think that's wrong.

Agreed. I did not foresee the case when libxml_xmlParserCtxtPtrWrap
is called on a context that was created outside the python bindings.

  The ctxt->_private should be set *only* when the Python routine
for associating private handlers to the context is called 
after checking
that such a block doesn't exist already. I see no reason why 
libxml_xmlParserCtxtPtrWrap() should be modified.


   I fixed this, integrated in the python/tests 
resulting in the enclosed patch, which was then commited to CVS



Here is an additional patch:
- to apply the same adaptation to xmlSetParserCtxtWarningHandler
- to DECREF stuff when changing the error and warning handlers
- and, while looking for the leak I introduced, I think I found
  a missing DECREF in pythonExternalEntityLoader

This time I ran the regression tests before posting
(and I promise to do so in the future...).


Attachment: ctxerror.patch2
Description: Binary data

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]