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.

Ok.

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

  thanks,

Thanks.

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...).

-sbi

Attachment: ctxerror.patch2
Description: Binary data



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