[Python-bugs-list] [Bug #111866] Overflow Error

noreply@sourceforge.net noreply@sourceforge.net
Mon, 14 Aug 2000 20:35:13 -0700


Bug #111866, was updated on 2000-Aug-14 07:21
Here is a current snapshot of the bug.

Project: Python
Category: Core
Status: Closed
Resolution: Fixed
Bug Group: None
Priority: 5
Summary: Overflow Error

Details: On Beta version of 1.6 for NT w/ Svc Pack 6. I get following error.
This used to work on both 1.5 and Alpha.
This is need to keep track of Non Numeric values.

>>> INF = 1e+110000
OverflowError: cannot convert float infinity to long


Follow-Ups:

Date: 2000-Aug-14 17:23
By: tim_one

Comment:
Curious.  It's an accident that it ever "worked" -- *any* visible behavior with infinities and NaNs is an accident in Python, as the language implementation knows nothing about them.

I'll get this to work somehow.  In the meantime, consider using

INF = 1e300**2

instead.  That still "works", although also by accident.  If you later try hash(INF), it will blow up with the same msg you originally got (your error actually occurs at compile-time, while Python is using an invisible dict to keep track of the constants it's seen -- your 1e+110000 actually works fine (although *that's* an accident of the way Microsoft's input routines work!), and it's the internal hashing of the resulting double value that blows up).

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

Date: 2000-Aug-14 20:35
By: tim_one

Comment:
Fixed in the CVS tree.  I don't intend to backstitch this into 1.6, though, because it required a lot of code shuffling in new-in-2.0 code.  The fix will be in the 2.0 release.  Following is the checkin msg:

Fix for http://sourceforge.net/bugs/?func=detailbug&bug_id=111866&group_id=5470.
This was a misleading bug -- the true "bug" was that hash(x) gave an error
return when x is an infinity.  Fixed that.  Added new Py_IS_INFINITY macro to
pyport.h.  Rearranged code to reduce growing duplication in hashing of float and
complex numbers, pushing Trent's earlier stab at that to a logical conclusion.
Fixed exceedingly rare bug where hashing of floats could return -1 even if there
wasn't an error (didn't waste time trying to construct a test case, it was simply
obvious from the code that it *could* happen).  Improved complex hash so that
hash(complex(x, y)) doesn't systematically equal hash(complex(y, x)) anymore.
CVS: ----------------------------------------------------------------------
CVS: Enter Log.  Lines beginning with `CVS:' are removed automatically
CVS: 
CVS: Committing in .
CVS: 
CVS: Modified Files:
CVS: 	python/dist/src/Include/pyport.h 
CVS: 	python/dist/src/Objects/complexobject.c 
CVS: 	python/dist/src/Objects/floatobject.c 
CVS: 	python/dist/src/Objects/longobject.c 
CVS: 	python/dist/src/Objects/object.c 
CVS: ----------------------------------------------------------------------


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

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=111866&group_id=5470