Re: [xml] using "raise" in Python error handler callbacks



On Thu, Mar 31, 2005 at 07:57:04PM -0500, Stefan Seefeld wrote:
Daniel Veillard wrote:
On Thu, Mar 31, 2005 at 10:25:41PM +0100, Andrew McDermott wrote:

Whilst experimenting with the Python bindings I noticed that exceptions 
are not propagated when using registerErrorHandler().  If I run the 
following I get the error message:

   /etc/passwd : failed to parse.

However, there is no Traceback for the "raise".  Is this correct?

import libxml2
import sys


 You have
   Python calling C calling Python.
the internal exception in the callback does not cross the C boundary
I don't see how this could work without disastrous side effects like
memory leaks or general instability in the program.

I don't think this is quite accurate. Think about python as a high-level
API to a C runtime. If the outer and the inner python runtimes are
the same, there is certainly a way to pass the necessary information through
(i.e. ultimately just preserve the exception state from the callback).

  If you know how to do it, I take patches. I don't know how to do it in
the general case, i.e. without changing all C APIs to have an extra argument
to carry those informations. And changing the public C APIs is not possible.
Again I take patches !

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]