[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] python3 issues
On Mon, Apr 01, 2019 at 10:59:05AM +0100, M A Young wrote: > > > On Mon, 1 Apr 2019, Wei Liu wrote: > > > On Tue, Mar 26, 2019 at 10:06:48PM +0100, Hans van Kranenburg wrote: > > > > > > Python 3 no longer allows comparing string and int, because it doesn't > > > make sense. > > > > > > == sorted([1,2,3,'a','b','c']) > > > Traceback (most recent call last): > > > File "<stdin>", line 1, in <module> > > > TypeError: unorderable types: str() < int() > > > > > > So I guess that if the contents are expected to be "saved" or a number > > > as string like "1", "2", then: > > > > > > 1. check for "saved" > > > 2. try: int(val) except: blah > > > 3. etc > > > > > > > Actually I think you scheme here is better. Relying on string comparison > > seems to be error-prone. > > > > Wei. > > I tested with the patch > > --- xen-4.12.0-rc6/tools/pygrub/src/GrubConf.py.orig 2019-03-24 > 22:44:05.502581989 +0000 > +++ xen-4.12.0-rc6/tools/pygrub/src/GrubConf.py 2019-03-24 > 22:49:14.025934786 +0000 > @@ -233,7 +233,10 @@ > if val == "saved": > self._default = 0 > else: > - self._default = val > + try: > + self._default = int(val) > + except ValueError: > + self._default = 0 > > if self._default < 0: > raise ValueError("default must be positive number") > > which works for me but should probably have some logging added for debug > purposes. Ha, I have the exact same snippet in my patch. :-) Wei. > > Michael Young _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |