[virt-tools-list] [virt-manager PATCH] Avoid getting AttributeError when handling libvirt error

Daniel P. Berrange berrange at redhat.com
Tue Feb 5 12:44:11 UTC 2013


On Tue, Feb 05, 2013 at 12:36:16PM +0100, Martin Kletzander wrote:
> On 02/05/2013 11:14 AM, Daniel P. Berrange wrote:
> > On Mon, Feb 04, 2013 at 10:51:46PM +0100, Martin Kletzander wrote:
> >> My python libvirt module doesn't have VIR_ERR_* inside itself and
> >> according to some places in the code, this was already taken care of
> >> by using the 'getattr' with safe default.  However, there were still
> >> some places where this wasn't handled properly, so I tried to fixed it
> >> by adding getattr for these attributes wherever 'git grep VIR_ERR'
> >> found it.  While on that, I took the liberty of cleaning up some
> >> related lines that were too long.
> > 
> > This is a libvirt bug which virt-manager shouldn't work around.
> > The python bindings in the 1.0.2 release were broken.
> > 
> 
> But it looks like they are broken even in the current HEAD.  I'd like
> giving all the error handling a similar look and even though it's not
> necessarily needed, some places use 'getattr' already.  Could you have a
> look at my v2 and in case you still don't like it, I'll send a v3 for
> removing the 'getattr'?

The reason some places use 'getattr' is that the code wanted to be able
to check for a new type of error, without increasing the minimum
required libvirt-python version. Next time the min libvirt is updated,
then most of the getattr calls with go away, so we shouldn't be adding
more

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the virt-tools-list mailing list