changeset 77680:166599219bd4

Issue #14815: Use Py_ssize_t instead of long for the object hash, to preserve all 64 bits of hash on Win64.
author Larry Hastings <larry@hastings.org>
date Sun, 24 Jun 2012 01:54:21 -0700
parents d1c93a2ee324
children 0adccb941200
files Misc/NEWS Modules/_randommodule.c
diffstat 2 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Misc/NEWS	Sun Jun 24 01:27:51 2012 -0700
+++ b/Misc/NEWS	Sun Jun 24 01:54:21 2012 -0700
@@ -10,6 +10,9 @@
 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
--- a/Modules/_randommodule.c	Sun Jun 24 01:27:51 2012 -0700
+++ b/Modules/_randommodule.c	Sun Jun 24 01:54:21 2012 -0700
@@ -234,10 +234,10 @@
     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;