The 'PyErr_Occurred()' function will return 1 since the (python) error
callback raised an exception that was not yet dealt with.
With the above hack, the example of the OP indeed generates a stack trace
(a TypeError as the string in the 'raise' expression is malformed).
However, things are more complex than that, since xmlTextReaderRead will
potentially call the (python) callback multiple times, erasing the exception
state from former calls.
Right now libxml2 seems to assume that (error) callbacks can't fail
themselfs.
I'm not sure whether there is anything to do here.
So PyErr_Occurred() check should be done when C call python at the,
return point, right ?
I think this occurs only in a few places within python/libxml.c which is
not autogenerated. So hacking this might be possible.