[xml] debug not correctly flagged in python wrappers?



This code:

  import string
  import libxml2
  import libxslt

  def f(ctx, *str):
      return str[0]

  libxslt.registerExtModuleFunction("foo", "http://example.com/foo";, f)
  styledoc = libxml2.parseDoc("""
  <xsl:stylesheet version='1.0'
    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
    xmlns:foo='http://example.com/foo'
    xsl:exclude-result-prefixes='foo'>
    <xsl:template match='/'>
      <xsl:variable name="myvar" select="/doc"/>
      <test><xsl:copy-of select="foo:foo($myvar)"/></test>
    </xsl:template>
  </xsl:stylesheet>
  """)
  style = libxslt.parseStylesheetDoc(styledoc)
  doc = libxml2.parseDoc("<doc/>")
  result = style.applyStylesheet(doc, {})
  print result
  style.freeStylesheet()
  doc.freeDoc()

Produces this output on stdout:

  Got a CObject
  <?xml version="1.0"?>
  <test><doc/></test>


It seems that in types.c there are some printf's that look like debug
but aren't marked as such.

Here's a patch:

diff -u libxslt/python/types.c.\~1.4.\~ libxslt/python/types.c
--- libxslt/python/types.c.~1.4.~       2003-08-07 13:03:01.000000000 +0000
+++ libxslt/python/types.c      2006-02-22 14:09:02.000000000 +0000
@@ -401,7 +401,9 @@
         case XPATH_RANGE:
         case XPATH_LOCATIONSET:
         default:
+#ifdef DEBUG
             printf("Unable to convert XPath object type %d\n", obj->type);
+#endif
             Py_INCREF(Py_None);
             ret = Py_None;
     }
@@ -446,7 +448,9 @@
 
             cur = NULL;
             if (PyCObject_Check(node)) {
+#ifdef DEBUG
                 printf("Got a CObject\n");
+#endif                
                 cur = PyxmlNode_Get(node);
             } else if (PyInstance_Check(node)) {
                 PyInstanceObject *inst = (PyInstanceObject *) node;
@@ -466,7 +470,9 @@
                     }
                     }
             } else {
+#ifdef DEBUG                
                 printf("Unknown object in Python return list\n");
+#endif
             }
             if (cur != NULL) {
                 xmlXPathNodeSetAdd(set, cur);
@@ -474,7 +480,9 @@
         }
         ret = xmlXPathWrapNodeSet(set);
     } else {
+#ifdef DEBUG                        
         printf("Unable to convert Python Object to XPath");
+#endif
     }
     Py_DECREF(obj);
     return (ret);

Diff finished.  Wed Feb 22 14:09:25 2006


I think this is probably correct...


Nic



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