]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 69433,69436 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Sun, 8 Feb 2009 14:56:08 +0000 (14:56 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Sun, 8 Feb 2009 14:56:08 +0000 (14:56 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r69433 | mark.dickinson | 2009-02-08 13:58:10 +0000 (Sun, 08 Feb 2009) | 2 lines

  Remove redundant assignment in _PyObject_LengthHint
........
  r69436 | mark.dickinson | 2009-02-08 14:42:28 +0000 (Sun, 08 Feb 2009) | 10 lines

  Issue #789290: make sure that hash(2**63) == hash(2.**63) on 64-bit
  platforms.  The previous code was fragile, depending on the twin
  accidents that:

    (1) in C, casting the double value 2.**63 to long returns the integer
        value -2**63, and
    (2) in Python, hash(-2**63) == hash(2**63).

  There's already a test for this in test_hash.
........

Objects/abstract.c
Objects/object.c

index b47b1c9772fa8f0b03d0997ca1b324c02b371cc7..de8682a8ab4f7640ba96440345c22d276ed1bda2 100644 (file)
@@ -123,7 +123,7 @@ _PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
                PyErr_Clear();
                return defaultvalue;
        }
-       rv = rv = PyLong_Check(ro) ? PyLong_AsSsize_t(ro) : defaultvalue;
+       rv = PyLong_Check(ro) ? PyLong_AsSsize_t(ro) : defaultvalue;
        Py_DECREF(ro);
        return rv;
 }
index 7b82db9d43b4fbe1d42f9ecd6407c856a35ec708..daee6fb339e3fcfbd8e5a506fc448f444eae97c5 100644 (file)
@@ -1023,7 +1023,7 @@ _Py_HashDouble(double v)
        fractpart = modf(v, &intpart);
        if (fractpart == 0.0) {
                /* This must return the same hash as an equal int or long. */
-               if (intpart > LONG_MAX || -intpart > LONG_MAX) {
+               if (intpart > LONG_MAX/2 || -intpart > LONG_MAX/2) {
                        /* Convert to long and use its hash. */
                        PyObject *plong;        /* converted to Python long */
                        if (Py_IS_INFINITY(intpart))