1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-20 03:52:25 +03:00

Fix python bindings with versions older than 2.7

Need fixing on the Capsule usage, the lack of PyBytes,
lack of io module and the way to access exception details.
This commit is contained in:
Daniel Veillard
2013-04-02 10:27:57 +08:00
parent 4d7a32959b
commit bf4a8f0ea8
8 changed files with 39 additions and 11 deletions

View File

@@ -384,19 +384,29 @@ libxml_xmlParserCtxtPtrWrap(xmlParserCtxtPtr ctxt)
/**
* libxml_xmlXPathDestructNsNode:
* cobj: xmlNsPtr namespace node capsule object
* cap: xmlNsPtr namespace node capsule object
*
* This function is called if and when a namespace node returned in
* an XPath node set is to be destroyed. That's the only kind of
* object returned in node set not directly linked to the original
* xmlDoc document, see xmlXPathNodeSetDupNs.
*/
#if PY_VERSION_HEX < 0x02070000
static void
libxml_xmlXPathDestructNsNode(PyObject *cap) {
#ifdef DEBUG
fprintf(stderr, "libxml_xmlXPathDestructNsNode called %p\n", cobj);
libxml_xmlXPathDestructNsNode(void *cap, void *desc ATTRIBUTE_UNUSED)
#else
static void
libxml_xmlXPathDestructNsNode(PyObject *cap)
#endif
{
#ifdef DEBUG
fprintf(stderr, "libxml_xmlXPathDestructNsNode called %p\n", cap);
#endif
#if PY_VERSION_HEX < 0x02070000
xmlXPathNodeSetFreeNs((xmlNsPtr) cap);
#else
xmlXPathNodeSetFreeNs((xmlNsPtr) PyCapsule_GetPointer(cap, "xmlNsPtr"));
#endif
}
PyObject *
@@ -658,7 +668,7 @@ libxml_xmlXPathObjectPtrConvert(PyObject * obj)
cur = NULL;
if (PyCapsule_CheckExact(node)) {
#ifdef DEBUG
printf("Got a CObject\n");
printf("Got a Capsule\n");
#endif
cur = PyxmlNode_Get(node);
} else if ((PyObject_HasAttrString(node, (char *) "_o")) &&