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/
Home Products Support Community News


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: Kaleb Pederson <kibab@xxxxxxxxxxxx>
Date: Thu, 18 May 2006 22:44:43 -0700
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 18 May 2006 22:45:16 -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: KMail/1.9.1
On Thursday 18 May 2006 3:14 pm, Ewan Mellor wrote:
> On Thu, May 18, 2006 at 12:31:53PM -0700, Kaleb Pederson wrote:
> 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.

So this should work, but doesn't either:

>>> import xen.lowlevel.xc as xc
>>> import exceptions
>>> x = xc.xc()
>>> try:
...     x.bvtsched_domain_get(0)
... except exceptions.RuntimeError, e:
...     print "Caught RuntimeError"
Traceback (most recent call last):
  File "<stdin>", line 2, in ?
xen.lowlevel.xc.error: (22, 'Invalid argument')

I also confirmed with isinstance, and exception is the only one of 
exceptions.* that it inherits from.

I'm not familiar with the Python C API at all, but I did a bit of digging 

from tools/python/xen/lowlevel/xc/xc.c:

#define PKG "xen.lowlevel.xc"
    xc_error = PyErr_NewException(PKG ".error", NULL, NULL);

So, the name displayed (xen.lowlevel.xc.error) is defined based on the call 
above.  I found the python docs for PyErr_NewException:

PyObject* PyErr_NewException(  char *name, PyObject *base, PyObject *dict)
Return value: New reference. 
 This utility function creates and returns a new exception object. The name 
argument must be the name of the new exception, a C string of the form 
module.class. The base and dict arguments are normally NULL. This creates a 
class object derived from the root for all exceptions, the built-in name 
Exception (accessible in C as PyExc_Exception). The __module__ attribute of 
the new class is set to the first part (up to the last dot) of the name 
argument, and the class name is set to the last part (after the last dot). 
The base argument can be used to specify an alternate base class. The dict 
argument can be used to specify a dictionary of class variables and methods.

So, per the docs, it is only derived from Exception.  It would be much nicer 
if it were derived from some other exception class... say XenException or 



Attachment: pgpq0E2Ur47Vr.pgp
Description: PGP signature

Xen-devel mailing list