bugfix for longobject.c (all versions)

Guido.van.Rossum@cwi.nl
Mon, 18 Jan 1993 10:53:49 +0100

I've been told that there's a bug in the comparison of negative long
integers. It's a record-breaking bug, since it has existed since the
very first implementation of long ints! So maybe it isn't of critical
importance, but since I've just found a 2-line fix I don't want to
withhold that from y'all.

You don't need to test whether you have the bug -- I'm sure you have
it, but in case you're interested, it turns out that -2L compares
greater than -1L ... Apply this patch to longobject and it's fixed...
(Not that you care -- or else why did nobody complain before?)

===================================================================
RCS file: /ufs/guido/CVSROOT/python/src/longobject.c,v
retrieving revision 1.17
diff -c -1 -r1.17 longobject.c
*** 1.17 1992/09/17 17:54:47
--- longobject.c 1993/01/18 09:16:05
***************
*** 608,611 ****
sign = 0;
! else
sign = (int)a->ob_digit[i] - (int)b->ob_digit[i];
}
--- 608,614 ----
sign = 0;
! else {
sign = (int)a->ob_digit[i] - (int)b->ob_digit[i];
+ if (a->ob_size < 0)
+ sign = -sign;
+ }
}
===================================================================

Note that this doesn't mean I'll soon bring out a new release -- 0.9.8
appears quite stable, there have been a number of problem reports but
these all pertain to minor things that can be fixed by massaging the
Makefile a little bit, or they are very platform-specific (hallo Jaap!).

Cheers,

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>