[Lxml-checkins] r53787 - in lxml/trunk: . src/lxml src/lxml/tests

scoder at codespeak.net scoder at codespeak.net
Tue Apr 15 16:54:09 CEST 2008


Author: scoder
Date: Tue Apr 15 16:54:07 2008
New Revision: 53787

Modified:
   lxml/trunk/   (props changed)
   lxml/trunk/CHANGES.txt
   lxml/trunk/src/lxml/tests/test_xslt.py
   lxml/trunk/src/lxml/xslt.pxi
Log:
 r3978 at delle:  sbehnel | 2008-04-15 16:52:51 +0200
 some XSLT errors could pass silently


Modified: lxml/trunk/CHANGES.txt
==============================================================================
--- lxml/trunk/CHANGES.txt	(original)
+++ lxml/trunk/CHANGES.txt	Tue Apr 15 16:54:07 2008
@@ -19,6 +19,9 @@
 Bugs fixed
 ----------
 
+* lxml did not honour libxslt's second error state "STOPPED", which
+  let some XSLT errors pass silently.
+
 * Memory leak in Schematron with libxml2 >= 2.6.31.
 
 * lxml.etree accepted non well-formed namespace prefix names.

Modified: lxml/trunk/src/lxml/tests/test_xslt.py
==============================================================================
--- lxml/trunk/src/lxml/tests/test_xslt.py	(original)
+++ lxml/trunk/src/lxml/tests/test_xslt.py	Tue Apr 15 16:54:07 2008
@@ -299,11 +299,12 @@
 ''',
                           str(res))
 
-    def _test_xslt_parameter_invalid(self):
+    def test_xslt_parameter_invalid(self):
         tree = self.parse('<a><b>B</b><c>C</c></a>')
         style = self.parse('''\
 <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:param name="bar"/>
   <xsl:template match="/">
     <foo><xsl:value-of select="$bar" /></foo>
   </xsl:template>
@@ -311,8 +312,6 @@
 
         st = etree.XSLT(style)
         res = self.assertRaises(etree.XSLTApplyError,
-                                st, tree, bar="test")
-        res = self.assertRaises(etree.XSLTApplyError,
                                 st, tree, bar="<test/>")
         res = self.assertRaises(etree.XSLTApplyError,
                                 st, tree, bar="....")
@@ -521,8 +520,8 @@
         source = self.parse(xml)
         styledoc = self.parse(xslt)
         style = etree.XSLT(styledoc)
-        result = style(source)
-        self.assertEqual('', str(result))
+
+        self.assertRaises(etree.XSLTApplyError, style, source)
         self.assert_("TEST TEST TEST" in [entry.message
                                           for entry in style.error_log])
 

Modified: lxml/trunk/src/lxml/xslt.pxi
==============================================================================
--- lxml/trunk/src/lxml/xslt.pxi	(original)
+++ lxml/trunk/src/lxml/xslt.pxi	Tue Apr 15 16:54:07 2008
@@ -481,6 +481,11 @@
             c_result = self._run_transform(
                 c_doc, _kw, context, transform_ctxt)
 
+            if transform_ctxt.state != xslt.XSLT_STATE_OK:
+                if c_result is not NULL:
+                    tree.xmlFreeDoc(c_result)
+                    c_result = NULL
+
             if transform_ctxt.profile:
                 c_profile_doc = xslt.xsltGetProfileInformation(transform_ctxt)
                 if c_profile_doc is not NULL:


More information about the lxml-checkins mailing list