]> granicus.if.org Git - python/commitdiff
Issue #14815: Use Py_ssize_t instead of long for the object hash, to
authorLarry Hastings <larry@hastings.org>
Sun, 24 Jun 2012 08:54:21 +0000 (01:54 -0700)
committerLarry Hastings <larry@hastings.org>
Sun, 24 Jun 2012 08:54:21 +0000 (01:54 -0700)
preserve all 64 bits of hash on Win64.

Misc/NEWS
Modules/_randommodule.c

index c429412788bd7cf3f5461336682feeed65ab7c84..3a07f03fdc75f67e99d62e8e54cce71f6f7938d8 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Beta 1?
 Core and Builtins
 -----------------
 
+- Issue #14815: Use Py_ssize_t instead of long for the object hash, to
+  preserve all 64 bits of hash on Win64.
+
 - Issue #12268: File readline, readlines and read() or readall() methods
   no longer lose data when an underlying read system call is interrupted.
   IOError is no longer raised due to a read system call returning EINTR
index 3c7d70083a98934d65abc82eb6c9f63c4e102d11..52530e6154b1abaebb3c95ab84901399357599ef 100644 (file)
@@ -234,10 +234,10 @@ random_seed(RandomObject *self, PyObject *args)
     if (PyLong_Check(arg))
         n = PyNumber_Absolute(arg);
     else {
-        long hash = PyObject_Hash(arg);
+        Py_ssize_t hash = PyObject_Hash(arg);
         if (hash == -1)
             goto Done;
-        n = PyLong_FromUnsignedLong((unsigned long)hash);
+        n = PyLong_FromSsize_t(hash);
     }
     if (n == NULL)
         goto Done;