|
|
|
|
|
|
|
|
|
|
xen-devel
Re: [Xen-devel] python bindings: xen.lowlevel.xc.error
Ewan Mellor wrote:
Did I miss something? If not, could the xen.lowlevel.xc.error class be
publically exposed?
They are exceptions of the built-in type RuntimeError -- that's what you get
when you use PyErr_SetFromErrno in the C layer. I don't know why it shows up
as xc.error -- presumably that's a Python internal thing.
Actually, these exceptions are rather weird. This is pretty much
pushing my Python understanding to the limit but I looked into this a
while back and came to this conclusion.
These are not RuntimeError exceptions but rather of the type xc.error.
This type is created in initxc() with PyErr_NewException().
The weird thing is, this type is not exposed through the modules export
list so you cannot ever directly reference the type. However, type() of
the exception will return xc.error.
The PyErr_SetFromErrno is just a helper that instantiates an exception
of a given type and sets the value of the exception to a tuple
containing the errno and message.
As a hack, I changed xc_error to be initialized to PyExc_OSError which
allowed errors to be caught appropriately. I don't know if this is the
Right Thing to do from a Python perspective (if libxc were in Python,
the failures would get propagated as OSErrors so it sort of makes sense).
In the very least, we probably have to somehow expose the exception type
within the module. It's quite unfortunately that everywhere in Xend
just catches any exception.
Any Python gurus out there that can shed some light on the proper thing
we should be doing? It's an easy patch once we know what the right
thing to do is.
Regards,
Anthony Liguori
Ewan.
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
|
|
|
|