Raise OverflowError when appropriate on long->float conversion. Most of
the fiddling is simply due to that no caller of PyLong_AsDouble ever
checked for failure (so that's fixing old bugs). PyLong_AsDouble is much
faster for big inputs now too, but that's more of a happy consequence
than a design goal.
diff --git a/Misc/NEWS b/Misc/NEWS
index 43eff32..a8f05c7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -3,6 +3,9 @@
Core
+- Conversion of long to float now raises OverflowError if the long is too
+ big to represent as a C double.
+
- The 3-argument builtin pow() no longer allows a third non-None argument
if either of the first two arguments is a float, or if both are of
integer types and the second argument is negative (in which latter case
@@ -95,6 +98,15 @@
API
+- Note that PyLong_AsDouble can fail! This has always been true, but no
+ callers checked for it. It's more likely to fail now, because overflow
+ errors are properly detected now. The proper way to check:
+
+ double x = PyLong_AsDouble(some_long_object);
+ if (x == -1.0 && PyErr_Occurred()) {
+ /* The conversion failed. */
+ }
+
- The GC API has been changed. Extensions that use the old API will still
compile but will not participate in GC. To upgrade an extension
module: