From: Kaleb Pederson Subject: Re: python bindings: xen.lowlevel.xc.error Date: Thu, 18 May 2006 22:44:43 -0700 Message-ID: <200605182244.47146.kibab@icehouse.net> References: <20060518193153.GB24931@kibab> <20060518221445.GB30245@leeni.uk.xensource.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1186092599==" Return-path: In-Reply-To: <20060518221445.GB30245@leeni.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Mime-version: 1.0 Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Ewan Mellor Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --===============1186092599== Content-Type: multipart/signed; boundary="nextPart4771541.c9v5Q5tbyM"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart4771541.c9v5Q5tbyM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thursday 18 May 2006 3:14 pm, Ewan Mellor wrote: > On Thu, May 18, 2006 at 12:31:53PM -0700, Kaleb Pederson wrote: [snip] > > 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 =3D xc.xc() >>> try: =2E.. x.bvtsched_domain_get(0) =2E.. except exceptions.RuntimeError, e: =2E.. print "Caught RuntimeError" =2E.. Traceback (most recent call last): File "", line 2, in ? xen.lowlevel.xc.error: (22, 'Invalid argument') I also confirmed with isinstance, and exception is the only one of=20 exceptions.* that it inherits from. I'm not familiar with the Python C API at all, but I did a bit of digging=20 around: from tools/python/xen/lowlevel/xc/xc.c: =2E.. #define PKG "xen.lowlevel.xc" =2E.. xc_error =3D PyErr_NewException(PKG ".error", NULL, NULL); =2E.. So, the name displayed (xen.lowlevel.xc.error) is defined based on the call= =20 above. I found the python docs for PyErr_NewException: " PyObject* PyErr_NewException( char *name, PyObject *base, PyObject *dict) Return value: New reference.=20 This utility function creates and returns a new exception object. The name= =20 argument must be the name of the new exception, a C string of the form=20 module.class. The base and dict arguments are normally NULL. This creates a= =20 class object derived from the root for all exceptions, the built-in name=20 Exception (accessible in C as PyExc_Exception). The __module__ attribute of= =20 the new class is set to the first part (up to the last dot) of the name=20 argument, and the class name is set to the last part (after the last dot).= =20 The base argument can be used to specify an alternate base class. The dict= =20 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 nice= r=20 if it were derived from some other exception class... say XenException or=20 something.... Thanks. =2D-Kaleb --nextPart4771541.c9v5Q5tbyM Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQBEbVtPeAVt8Tl/2kURAoyJAJ4+pOIy9btc27xoridZqhV4Z36S3gCfeuqe KCwVcfTDz0C/W59WZiPwEvE= =7mkk -----END PGP SIGNATURE----- --nextPart4771541.c9v5Q5tbyM-- --===============1186092599== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1186092599==--