diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-09-23 08:06:40 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-09-23 08:06:40 (GMT) |
commit | 307fa78107c39ffda1eb4ad18201d25650354c4e (patch) | |
tree | 6b2daf6dc3169cfc2054ebc4162647b5c647d875 /Misc | |
parent | 4533f1fb7fbf1fa8a9cb264ff6f1f0aba043e80d (diff) | |
download | cpython-307fa78107c39ffda1eb4ad18201d25650354c4e.zip cpython-307fa78107c39ffda1eb4ad18201d25650354c4e.tar.gz cpython-307fa78107c39ffda1eb4ad18201d25650354c4e.tar.bz2 |
SF bug #513866: Float/long comparison anomaly.
When an integer is compared to a float now, the int isn't coerced to float.
This avoids spurious overflow exceptions and insane results. This should
compute correct results, without raising spurious exceptions, in all cases
now -- although I expect that what happens when an int/long is compared to
a NaN is still a platform accident.
Note that we had potential problems here even with "short" ints, on boxes
where sizeof(long)==8. There's #ifdef'ed code here to handle that, but
I can't test it as intended. I tested it by changing the #ifdef to
trigger on my 32-bit box instead.
I suppose this is a bugfix candidate, but I won't backport it. It's
long-winded (for speed) and messy (because the problem is messy). Note
that this also depends on a previous 2.4 patch that introduced
_Py_SwappedOp[] as an extern.
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -15,7 +15,14 @@ Core and builtins - The bytecode optimizer now folds tuples of constants into a single constant. -- PyLong_AsUnsignedLong[Mask] now support int objects as well. +- SF bug #513866: Float/long comparison anomaly. Prior to 2.4b1, when + an integer was compared to a float, the integer was coerced to a float. + That could yield spurious overflow errors (if the integer was very + large), and to anomalies such as + ``long(1e200)+1 == 1e200 == long(1e200)-1``. Coercion to float is no + longer performed, and cases like ``long(1e200)-1 < 1e200``, + ``long(1e200)+1 > 1e200`` and ``(1 << 20000) > 1e200`` are computed + correctly now. Extension modules ----------------- @@ -72,6 +79,8 @@ Build C API ----- +- PyLong_AsUnsignedLong[Mask] now support int objects as well. + - SF patch #998993: ``PyUnicode_DecodeUTF8Stateful`` and ``PyUnicode_DecodeUTF16Stateful`` have been added, which implement stateful decoding. |