Message17788
Logged In: YES
user_id=652073
The bug is overflow (i.e. undefined behaviour), and so
the symptoms will vary according to the system. Under
the conditions I was running, there was no output,
because Python terminated with a SIGFPE. As I said, it
could as easily show up as erroneous results.
In THIS case, the failure occurs in the input processing,
and the purpose of prefixing it by print and int() is if
you try it on a system where it gives wrong answers. If
you don't have access to a system where overflow can be
turned on or one that uses unusual arithmetic, you will not
be able to repeat it. That is why I created a fix.
The reason that I didn't attach is is that attachment was
broken; I don't know why, and have neither the time nor the
inclination to debug a Web interface that I do not manage.
I can trivially send such things by Email, which is far
more reliable. There doesn't appear to be a mechanism to
try again, so here is a context diff:
*** object.c.org Wed Feb 19 03:21:21 2003
--- object.c Fri Aug 15 15:22:50 2003
***************
*** 955,962 ****
long
_Py_HashDouble(double v)
{
! double intpart, fractpart;
! int expo;
long hipart;
long x; /* the final hash value */
/* This is designed so that Python numbers of
different types
--- 955,962 ----
long
_Py_HashDouble(double v)
{
! double intpart, fractpart, z;
! int expo, i, j;
long hipart;
long x; /* the final hash value */
/* This is designed so that Python numbers of
different types
***************
*** 975,981 ****
#endif
if (fractpart == 0.0) {
/* This must return the same hash as an
equal int or long. */
! if (intpart > LONG_MAX || -intpart >
LONG_MAX) {
/* Convert to long and use its hash.
*/
PyObject *plong; /* converted
to Python long */
if (Py_IS_INFINITY(intpart))
--- 975,992 ----
#endif
if (fractpart == 0.0) {
/* This must return the same hash as an
equal int or long. */
! /* Remember that (double)LONG_MAX can round
either way. */
! if (intpart > LONG_MIN/2 && intpart <
LONG_MAX/2)
! z = 0.0;
! else {
! z = (intpart >= 0.0 ? intpart :
-intpart);
! for (i =
(sizeof(long)*CHAR_BIT-1)/16; i >= 0; --i) {
! x = LONG_MAX;
! for (j = 0; j < i; ++j) x
>>= 16;
! z -= ldexp(x&0xffff,16*i);
! }
! }
! if (z > 0.0) {
/* Convert to long and use its hash.
*/
PyObject *plong; /* converted
to Python long */
if (Py_IS_INFINITY(intpart))
|
|
| Date |
User |
Action |
Args |
| 2007-08-23 14:16:08 | admin | link | issue789290 messages |
| 2007-08-23 14:16:08 | admin | create | |
|