commiting some Python bindings work done while travelling Daniel
* python/*: commiting some Python bindings work done while travelling
Daniel
diff --git a/python/types.c b/python/types.c
index d9fbd94..81865df 100644
--- a/python/types.c
+++ b/python/types.c
@@ -346,7 +346,7 @@
xmlXPathObjectPtr
libxml_xmlXPathObjectPtrConvert(PyObject * obj) {
- xmlXPathObjectPtr ret;
+ xmlXPathObjectPtr ret = NULL;
#ifdef DEBUG
printf("libxml_xmlXPathObjectPtrConvert: obj = %p\n", obj);
@@ -362,6 +362,25 @@
str = xmlStrndup((const xmlChar *)PyString_AS_STRING(obj),
PyString_GET_SIZE(obj));
ret = xmlXPathWrapString(str);
+ } else if PyList_Check(obj) {
+ int i;
+ PyObject *node;
+ xmlNodePtr cur;
+ xmlNodeSetPtr set;
+
+ set = xmlXPathNodeSetCreate(NULL);
+
+ for (i = 0;i < PyList_Size(obj);i++) {
+ node = PyList_GetItem(obj, i);
+ if ((node == NULL) || (node->ob_type == NULL) ||
+ (!PyCObject_Check(node)))
+ continue;
+ cur = PyxmlNode_Get(node);
+ if (cur != NULL) {
+ xmlXPathNodeSetAdd(set, cur);
+ }
+ }
+ ret = xmlXPathWrapNodeSet(set);
} else {
printf("Unable to convert Python Object to XPath");
}