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: Anthony Liguori <aliguori@xxxxxxxxxx>
Subject: Re: [Xen-devel] python bindings: xen.lowlevel.xc.error
From: Ewan Mellor <ewan@xxxxxxxxxxxxx>
Date: Fri, 19 May 2006 16:11:38 +0100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Kaleb Pederson <kibab@xxxxxxxxxxxx>
Delivery-date: Fri, 19 May 2006 08:12:02 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <446D6B57.9070804@xxxxxxxxxx>
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> <446D6B57.9070804@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
On Fri, May 19, 2006 at 01:53:11AM -0500, Anthony Liguori wrote:

> 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.

Yes, you're right, my mistake.  The ones in xs.c do
PyErr_SetFromErrno(PyExc_RuntimeError), that's where I got that from.

> 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.

If we're going to make a change at all, we ought to do it properly.  We should
have an exception for each of the xc and the xs modules, exposed through the
module interface correctly.  I don't have a problem with the exception being
derived directly from Exception, though if we're going to change xs.c as well
as xc.c, then we ought to inherit from RuntimeError, for compatibility with
the Python layer.

Can one of you two submit a patch?

Cheers,

Ewan.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>