[Libvir] [PATCH] Python bindings now generate exceptions for libvirt errors

Daniel Veillard veillard at redhat.com
Wed Mar 28 09:16:29 UTC 2007


On Tue, Mar 27, 2007 at 12:45:13PM +0100, Richard W.M. Jones wrote:
> Following on from this thread:
> https://www.redhat.com/archives/libvir-list/2007-March/thread.html#00341
> 
> The first attachment is a patch which changes the generated Python 
> bindings so that they always raise an exception when an underlying error 
> occurs in the C libvirt library.
> 
> The second attachment is for information only (not to be applied) - it 
> shows the differences in the generated file libvirtclass.py.  I have 
> checked each of these changes by hand against both the libvirt.c 
> interface description and the C implementation of the Python bindings 
> (libvir.c and libvirt-py.c), and each change seems correct.
> 
> I have _not_ tested this against virt-manager.  It is quite possible 
> that virt-manager will cease to work if it wasn't checking the return 
> values from affected functions carefully.  I'll check this later today 
> and supply a patch (to virt-manager) if necessary.
> 
> I have some additional questions about the Python bindings, but I'll put 
> those in a separate thread.

  That makes sense, my only worry is about the effect in applications, but
it's really cleaner from a Python viewpoint to raise exceptions there, and
fix application code when it's not too late. I guess someone using for example
RHEL5 and updating their libvirt would also update python-virtinst and
virt-manager accordingly.
  Let's apply this, the earlier it's fixed the smaller the collateral damages !

  thanks a lot, especially for going though the rather tortuous generator.py
code ...

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard at redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/




More information about the libvir-list mailing list