All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Ewan Mellor <ewan@xensource.com>
Cc: xen-devel@lists.xensource.com, Kaleb Pederson <kibab@icehouse.net>
Subject: Re: python bindings: xen.lowlevel.xc.error
Date: Fri, 19 May 2006 01:53:11 -0500	[thread overview]
Message-ID: <446D6B57.9070804@us.ibm.com> (raw)
In-Reply-To: <20060518221445.GB30245@leeni.uk.xensource.com>

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@lists.xensource.com
> http://lists.xensource.com/xen-devel
>   

  parent reply	other threads:[~2006-05-19  6:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-18 19:31 python bindings: xen.lowlevel.xc.error Kaleb Pederson
2006-05-18 22:14 ` Ewan Mellor
2006-05-19  5:44   ` Kaleb Pederson
2006-05-19  6:53   ` Anthony Liguori [this message]
2006-05-19 15:11     ` Ewan Mellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=446D6B57.9070804@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=ewan@xensource.com \
    --cc=kibab@icehouse.net \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.