tools/pygrub: Fix error handling if no valid partitions are found
authorAndrew Cooper <andrew.cooper3@citrix.com>
Sat, 10 May 2014 01:18:33 +0000 (02:18 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 12 May 2014 14:52:43 +0000 (15:52 +0100)
commitd75215805ce6ed20b3807955fab6a7f7a3368bee
treee224715f693a7ff4d92583a5c31f2b490d901cf3
parentbfc2e6e9423da679a35f33a9c488060748d94844
tools/pygrub: Fix error handling if no valid partitions are found

If no partitions at all are found, pygrub never creates the name 'fs',
resulting in a NameError indicating the lack of fs, rather than a
RuntimeError explaining that no partitions were found.

Set fs to None right at the start, and use the pythonic idiom "if fs is None:"
to protect against otherwise valid values for fs which compare equal to
0/False.

Reported-by: Sven Köhler <sven.koehler@gmail.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/pygrub/src/pygrub