Comment 1 for bug 1255132

Revision history for this message
scoder (scoder) wrote :

Thanks for the report and the excellent test case. Here is a fix:

diff -r 74c41e0ab944 src/lxml/apihelpers.pxi
--- a/src/lxml/apihelpers.pxi Fri Nov 15 16:15:42 2013 +0100
+++ b/src/lxml/apihelpers.pxi Thu Nov 28 18:08:22 2013 +0100
@@ -58,7 +58,7 @@
     else:
         raise TypeError, u"Invalid input object: %s" % \
             python._fqtypename(input)
- if node is None:
+ if node is None or node._c_node.type != tree.XML_ELEMENT_NODE:
         raise ValueError, u"Input object has no element: %s" % \
             python._fqtypename(input)
     _assertValidNode(node)