From: Michal Novotny <minovotn@redhat.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: [PATCH] Make PyGrub run first entry in grub config when invalid default boot option provided
Date: Tue, 24 Mar 2009 10:21:38 +0100 [thread overview]
Message-ID: <49C8A622.9090509@redhat.com> (raw)
In-Reply-To: <18887.49660.721664.393967@mariner.uk.xensource.com>
[-- Attachment #1: Type: text/plain, Size: 823 bytes --]
Hi,
thanks for advice. Here's new and corrected version of the patch. Well,
the error here is IndexError, when an error occurs so the IndexError is
catched and not KeyError. I have also tried it with KeyError but it was
not working so IndexError is catched here.
Michal
Ian Jackson wrote:
> 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.
>
[-- Attachment #2: xen-pygrub-invalid-default-configuration.patch --]
[-- Type: text/plain, Size: 449 bytes --]
diff -r e1562a36094e tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub Thu Mar 19 17:04:06 2009 +0000
+++ b/tools/pygrub/src/pygrub Fri Mar 20 15:09:31 2009 +0100
@@ -530,7 +530,11 @@
print "No kernel image selected!"
sys.exit(1)
- img = g.cf.images[sel]
+ try:
+ img = g.cf.images[sel]
+ except IndexError:
+ img = g.cf.images[0]
+
grubcfg = { "kernel": None, "ramdisk": None, "args": None }
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2009-03-24 9:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-20 14:14 [PATCH] Make PyGrub run first entry in grub config when invalid default boot option provided Michal Novotny
2009-03-23 17:08 ` Ian Jackson
2009-03-24 9:21 ` Michal Novotny [this message]
2009-03-24 13:33 ` Ian Jackson
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=49C8A622.9090509@redhat.com \
--to=minovotn@redhat.com \
--cc=Ian.Jackson@eu.citrix.com \
--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.