mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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.
This commit is contained in:
parent
4533f1fb7f
commit
307fa78107
3 changed files with 318 additions and 11 deletions
11
Misc/NEWS
11
Misc/NEWS
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue