Set libxml2 bindings for python3

Problem

I am trying to build libxml bindings ( libxml2-2.7.8 ) for Python 3.2. When I run the following:

 ./configure --with-python=/usr/bin/python3.2 

Compiling libxml2-2.7.8 works ... but Python bindings for libxml2-2.7.8 dont!

Attempt to fix

  • Ported setup.py and generator.py (using 2to3 and some basic fixes on generator.py )
  • Fixed libxml.c and types.c as follows:
    • replace PyInt * with PyLong *
    • replace PyString * with PyBytes *

Current situation

Unfortunately, this was not enough. I ran python3.2 setup.py build and got the following error:

 types.c:594:17: error: 'PyInstanceObject' undeclared (first use in this function) 

I cannot find the Python3 equivalent of PyInstanceObject !

Has anyone been able to compile libxml2 bindings for Python 3?

Did I miss something??? Can anyone help ?: (

+4
source share
1 answer

PyInstanceObject is part of the support for older type types that was dropped in Python 3 and was deprecated since Python 2.2. The trick here is to first update the bindings to use the new-style classes, and then port to Python 3.

(Or use lxml, which wraps libxml2 in Pythonic XML classes).

I'm not 100% sure what a replacement is, I have never done old-style classes in C, but I think it's just PyObject.

+3
source

All Articles