diff --git a/src/lxml/tests/test_xslt.py b/src/lxml/tests/test_xslt.py index 6ee82c5..44f97db 100644 --- a/src/lxml/tests/test_xslt.py +++ b/src/lxml/tests/test_xslt.py @@ -259,6 +259,20 @@ class ETreeXSLTTestCase(HelperTestCase): self.assertRaises(etree.XSLTParseError, etree.XSLT, style) + exc = None + try: + etree.XSLT(style) + except etree.XSLTParseError as e: + exc = e + self.assertTrue(exc is not None) + self.assertTrue(len(e.error_log) == 4) + + errors = ''':0:0:ERROR:XSLT:ERR_OK: compilation error +:0:0:ERROR:XSLT:ERR_OK: xsltStylePreCompute: unknown xsl:foo +:0:0:ERROR:XSLT:ERR_OK: compilation error +:0:0:ERROR:XSLT:ERR_OK: xsltParseStylesheetTop: unknown foo element''' + self.assertEqual(str(e.error_log), errors) + def test_xslt_parameters(self): tree = self.parse('BC') style = self.parse('''\ diff --git a/src/lxml/xmlerror.pxi b/src/lxml/xmlerror.pxi index 5294b50..1869a0e 100644 --- a/src/lxml/xmlerror.pxi +++ b/src/lxml/xmlerror.pxi @@ -378,6 +378,7 @@ cdef class _ErrorLogContext: recursively stacked log contexts. """ cdef xmlerror.xmlStructuredErrorFunc old_error_func + cdef xmlerror.xmlGenericErrorFunc old_xslt_error_func cdef void* old_error_context cdef class _ErrorLog(_ListErrorLog): @@ -407,6 +408,8 @@ cdef class _ErrorLog(_ListErrorLog): self._logContexts.append(context) xmlerror.xmlSetStructuredErrorFunc( self, _receiveError) + xslt.xsltSetGenericErrorFunc( + self, _receiveXSLTError) return 0 @cython.final @@ -414,6 +417,8 @@ cdef class _ErrorLog(_ListErrorLog): cdef _ErrorLogContext context = self._logContexts.pop() xmlerror.xmlSetStructuredErrorFunc( context.old_error_context, context.old_error_func) + xslt.xsltSetGenericErrorFunc( + context.old_error_context, context.old_xslt_error_func) return 0 cpdef clear(self):