mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
pygrub/grub: always use integer for default entry
The original code set the default to either a string or an integer (0) and relies on a Python 2 specific behaviour to work (integer is allowed to be compared to string in Python 2 but not 3). Always use integer. The caller (pygrub) already has code to handle that. Reported-by: M A Young <m.a.young@durham.ac.uk> Signed-off-by: Wei Liu <wei.liu2@citrix.com> Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
This commit is contained in:
1 parent
485079e816
commit
767ba397d3
1 file changed
+5
-1
@@ -233,7 +233,11 @@ class _GrubConfigFile(object):
|
||||
if val == "saved":
|
||||
self._default = 0
|
||||
else:
|
||||
self._default = val
|
||||
try:
|
||||
self._default = int(val)
|
||||
except ValueError:
|
||||
logging.warning("Invalid value %s, setting default to 0" %(val,))
|
||||
self._default = 0
|
||||
|
||||
if self._default < 0:
|
||||
raise ValueError("default must be non-negative number")
|
||||
|
||||