[Python-bugs-list] [ python-Bugs-789159 ] Minor floatobject.c bug

SourceForge.net noreply at sourceforge.net
Fri Aug 15 06:44:18 EDT 2003


Bugs item #789159, was opened at 2003-08-15 06:39
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=789159&group_id=5470

Category: Python Interpreter Core
Group: Python 2.2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Nick Maclaren (nmm1)
Assigned to: Nobody/Anonymous (nobody)
Summary: Minor floatobject.c bug

Initial Comment:
The following is a previously reported bug that got
only half fixed.
The bug was closed before I could respond that the fix
was incomplete;
here is a complete fix.

The failure is when overflow checking is enabled on
integers, as is
good programming practice and permitted by the C
standard.  It could
also cause wrong answers if overflow is mishandled (as
is also permitted
and can happen).

*** ./Objects/floatobject.c.org Tue Jan 28 19:40:35
2003
--- ./Objects/floatobject.c     Tue Jun  3 13:02:48
2003
***************
*** 659,667 ****
           to long may yield gibberish in either case. 
What really matters
           is whether converting back to double again
reproduces what we
           started with. */
!       aslong = (long)wholepart;
!       if ((double)aslong == wholepart)
!               return PyInt_FromLong(aslong);
        PyErr_SetString(PyExc_OverflowError, "float too
large to convert");
        return NULL;
  }
--- 659,669 ----
           to long may yield gibberish in either case. 
What really matters
           is whether converting back to double again
reproduces what we
           started with. */
!         if (wholepart > LONG_MIN-1.0 && wholepart <
LONG_MAX+1.0) {
!               aslong = (long)wholepart;
!               if ((double)aslong == wholepart)
!                       return PyInt_FromLong(aslong);
!         }
        PyErr_SetString(PyExc_OverflowError, "float too
large to convert");
        return NULL;
  }

        
Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH,
England.
Email:  nmm1 at cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679



----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2003-08-15 08:44

Message:
Logged In: YES 
user_id=33168

Nick, if we do close a bug, you can still make comments and
we'll see it.  Thanks.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=789159&group_id=5470



More information about the Python-bugs-list mailing list