]> granicus.if.org Git - python/commitdiff
"Conceptual" merge of rev 51711 from the 2.5 branch.
authorTim Peters <tim.peters@gmail.com>
Tue, 5 Sep 2006 02:18:09 +0000 (02:18 +0000)
committerTim Peters <tim.peters@gmail.com>
Tue, 5 Sep 2006 02:18:09 +0000 (02:18 +0000)
i_divmod():  As discussed on Python-Dev, changed the overflow
checking to live happily with recent gcc optimizations that
assume signed integer arithmetic never overflows.

This differs from the corresponding change on the 2.5 and 2.4
branches, using a less obscure approach, but one that /may/
tickle platform idiocies in their definitions of LONG_MIN.
The 2.4 + 2.5 change avoided introducing a dependence on
LONG_MIN, at the cost of substantially goofier code.

Misc/NEWS
Objects/intobject.c

index b4e0b2549af2b738e67de9b6212d8ca7e8f39ccf..04c78c0dc21bcdd18800f678bd83c6610fc9cd31 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
 Core and builtins
 -----------------
 
+- Overflow checking code in integer division ran afoul of new gcc
+  optimizations.  Changed to be more standard-conforming.
+
 - Patch #1542451: disallow continue anywhere under a finally.
 
 
@@ -136,7 +139,7 @@ Library
 - The __repr__ method of a NULL ctypes.py_object() no longer raises
   an exception.
 
-- uuid.UUID now has a bytes_le attribute. This returns the UUID in 
+- uuid.UUID now has a bytes_le attribute. This returns the UUID in
   little-endian byte order for Windows. In addition, uuid.py gained some
   workarounds for clocks with low resolution, to stop the code yielding
   duplicate UUIDs.
@@ -295,7 +298,7 @@ Library
 - Bug #1002398: The documentation for os.path.sameopenfile now correctly
   refers to file descriptors, not file objects.
 
-- The renaming of the xml package to xmlcore, and the import hackery done 
+- The renaming of the xml package to xmlcore, and the import hackery done
   to make it appear at both names, has been removed.  Bug #1511497,
   #1513611, and probably others.
 
index c7137df40ba83df80c063a22b6a305c65d62a63d..cbca49524eedc107cfffe879f944f25d32e0562b 100644 (file)
@@ -565,7 +565,7 @@ i_divmod(register long x, register long y,
                return DIVMOD_ERROR;
        }
        /* (-sys.maxint-1)/-1 is the only overflow case. */
-       if (y == -1 && x < 0 && x == -x)
+       if (y == -1 && x == LONG_MIN)
                return DIVMOD_OVERFLOW;
        xdivy = x / y;
        xmody = x - xdivy * y;