WARNING - OLD ARCHIVES

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

xen-devel

Re: [Xen-devel] [PATCH] Make PyGrub run first entry in grub config when

To: Michal Novotny <minovotn@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] Make PyGrub run first entry in grub config when invalid default boot option provided
From: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Date: Mon, 23 Mar 2009 17:08:12 +0000
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 23 Mar 2009 10:08:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <49C3A4D6.5050501@xxxxxxxxxx>
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Newsgroups: chiark.mail.xen.devel
References: <49C3A4D6.5050501@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Michal Novotny writes ("[Xen-devel] [PATCH] Make PyGrub run first entry in grub 
config when invalid default boot option provided"):
> -    img = g.cf.images[sel]
> +    try:
> +        img = g.cf.images[sel]
> +    except:

It is not correct to do this on all exceptions.  (This is a common
mistake in Python.)  I assume that in your error case the images array
doesn't have the relevant entry and that your code should read:
  +        img = g.cf.images[sel]
  +    except KeyError:

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel