if coerce(1, 1L) != (1L, 1L): raise TestFailed, 'coerce(1, 1L)'
if fcmp(coerce(1L, 1.1), (1.0, 1.1)): raise TestFailed, 'coerce(1L, 1.1)'
+try: coerce(0.5, long("12345" * 1000))
+except OverflowError: pass
+else: raise TestFailed, 'coerce(0.5, long("12345" * 1000))'
+
print 'compile'
compile('print 1\n', '', 'exec')
for x in -2.0, -1.0, 0.0, 1.0, 2.0:
verify(float(long(x)) == x)
+ shuge = '12345' * 1000
huge = 1L << 30000
mhuge = -huge
- namespace = {'huge': huge, 'mhuge': mhuge, 'math': math}
+ namespace = {'huge': huge, 'mhuge': mhuge, 'shuge': shuge, 'math': math}
for test in ["float(huge)", "float(mhuge)",
"complex(huge)", "complex(mhuge)",
"complex(huge, 1)", "complex(mhuge, 1)",
"1. ** huge", "huge ** 1.", "1. ** mhuge", "mhuge ** 1.",
"math.sin(huge)", "math.sin(mhuge)",
"math.sqrt(huge)", "math.sqrt(mhuge)", # should do better
- "math.floor(huge)", "math.floor(mhuge)"]:
+ "math.floor(huge)", "math.floor(mhuge)",
+ "float(shuge) == long(shuge)"]:
try:
eval(test, namespace)
- Bastion.py and rexec.py are disabled. These modules are not safe in
Python 2.2. or 2.3.
+- SF #676155: fixed errors when trying to convert a long integer
+ into a float which couldn't fit.
+
- SF #660476 and #513033: broken threadstate swap in readline could
cause fatal errors when a readline hook was being invoked while a
background thread was active.
return 0;
}
else if (PyLong_Check(*pw)) {
- *pw = PyFloat_FromDouble(PyLong_AsDouble(*pw));
+ double x = PyLong_AsDouble(*pw);
+ if (x == -1.0 && PyErr_Occurred())
+ return -1;
+ *pw = PyFloat_FromDouble(x);
Py_INCREF(*pv);
return 0;
}