From: Wei Liu Date: Mon, 1 Apr 2019 10:32:36 +0000 (+0100) Subject: pygrub/grub: always use integer for default entry X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~2421 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=767ba397d34848c7e0c4e9cdfc5efa4e0cb61442;p=xen.git 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 Signed-off-by: Wei Liu Acked-by: Andrew Cooper --- diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py index 0204d410ac..594139bac7 100644 --- a/tools/pygrub/src/GrubConf.py +++ b/tools/pygrub/src/GrubConf.py @@ -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")