WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] python bindings: xen.lowlevel.xc.error

To: Ewan Mellor <ewan@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] python bindings: xen.lowlevel.xc.error
From: Anthony Liguori <aliguori@xxxxxxxxxx>
Date: Fri, 19 May 2006 01:53:11 -0500
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Kaleb Pederson <kibab@xxxxxxxxxxxx>
Delivery-date: Thu, 18 May 2006 23:53:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20060518221445.GB30245@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20060518193153.GB24931@kibab> <20060518221445.GB30245@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mail/News 1.5 (X11/20060309)
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