# HG changeset patch # Parent a071dfc78c525bb6fda60746bbe694ff1b257200 adapt to upcoming buffer changes in libxml2 2.9 diff -r a071dfc78c52 -r e5da17790fc2 src/lxml/includes/etree_defs.h --- a/src/lxml/includes/etree_defs.h Thu Aug 09 17:06:50 2012 +0200 +++ b/src/lxml/includes/etree_defs.h Thu Aug 09 18:24:42 2012 +0200 @@ -152,6 +152,13 @@ # define xmlSchematronSetValidStructuredErrors(ctxt, errorfunc, data) #endif +#include "libxml/tree.h" +#ifndef LIBXML2_NEW_BUFFER + typedef xmlBuffer xmlBuf; +# define xmlBufContent(buf) xmlBufferContent(buf) +# define xmlBufLength(buf) xmlBufferLength(buf) +#endif + /* libexslt 1.1.25+ support EXSLT functions in XPath */ #if LIBXSLT_VERSION < 10125 #define exsltDateXpathCtxtRegister(ctxt, prefix) diff -r a071dfc78c52 -r e5da17790fc2 src/lxml/includes/tree.pxd --- a/src/lxml/includes/tree.pxd Thu Aug 09 17:06:50 2012 +0200 +++ b/src/lxml/includes/tree.pxd Thu Aug 09 18:24:42 2012 +0200 @@ -285,9 +285,11 @@ ctypedef struct xmlBuffer + ctypedef struct xmlBuf # new in libxml2 2.9 + ctypedef struct xmlOutputBuffer: - xmlBuffer* buffer - xmlBuffer* conv + xmlBuf* buffer + xmlBuf* conv int error const_xmlChar* XML_XML_NAMESPACE @@ -359,6 +361,8 @@ cdef void xmlBufferFree(xmlBuffer* buf) nogil cdef const_xmlChar* xmlBufferContent(xmlBuffer* buf) nogil cdef int xmlBufferLength(xmlBuffer* buf) nogil + cdef const_xmlChar* xmlBufContent(xmlBuf* buf) nogil # new in libxml2 2.9 + cdef size_t xmlBufLength(xmlBuf* buf) nogil # new in libxml2 2.9 cdef int xmlKeepBlanksDefault(int val) nogil cdef xmlChar* xmlNodeGetBase(xmlDoc* doc, xmlNode* node) nogil cdef void xmlNodeSetBase(xmlNode* node, const_xmlChar* uri) nogil diff -r a071dfc78c52 -r e5da17790fc2 src/lxml/serializer.pxi --- a/src/lxml/serializer.pxi Thu Aug 09 17:06:50 2012 +0200 +++ b/src/lxml/serializer.pxi Thu Aug 09 18:24:42 2012 +0200 @@ -81,7 +81,7 @@ tree. """ cdef tree.xmlOutputBuffer* c_buffer - cdef tree.xmlBuffer* c_result_buffer + cdef tree.xmlBuf* c_result_buffer cdef tree.xmlCharEncodingHandler* enchandler cdef const_char* c_enc cdef const_xmlChar* c_version @@ -133,11 +133,11 @@ try: if encoding is _unicode: - result = (tree.xmlBufferContent( - c_result_buffer))[:tree.xmlBufferLength(c_result_buffer)].decode('UTF-8') + result = (tree.xmlBufContent( + c_result_buffer))[:tree.xmlBufLength(c_result_buffer)].decode('UTF-8') else: - result = (tree.xmlBufferContent( - c_result_buffer))[:tree.xmlBufferLength(c_result_buffer)] + result = (tree.xmlBufContent( + c_result_buffer))[:tree.xmlBufLength(c_result_buffer)] finally: error_result = tree.xmlOutputBufferClose(c_buffer) if error_result < 0: @@ -287,6 +288,9 @@ tree.xmlOutputBufferWrite(c_buffer, 3, ' [\n') if c_dtd.notations != NULL: - tree.xmlDumpNotationTable(c_buffer.buffer, - c_dtd.notations) + c_buf = tree.xmlBufferCreate() + tree.xmlDumpNotationTable(c_buf, c_dtd.notations) + tree.xmlOutputBufferWrite( + c_buffer, tree.xmlBufferLength(c_buf), tree.xmlBufferContent(c_buf)) + tree.xmlBufferFree(c_buf) c_node = c_dtd.children while c_node is not NULL: