Skip to content

Commit 49c15d4

Browse files
committed
Issue #14815: Use Py_ssize_t instead of long for the object hash, to
preserve all 64 bits of hash on Win64.
1 parent 1bc276d commit 49c15d4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Beta 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #14815: Use Py_ssize_t instead of long for the object hash, to
14+
preserve all 64 bits of hash on Win64.
15+
1316
- Issue #12268: File readline, readlines and read() or readall() methods
1417
no longer lose data when an underlying read system call is interrupted.
1518
IOError is no longer raised due to a read system call returning EINTR

Modules/_randommodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ random_seed(RandomObject *self, PyObject *args)
234234
if (PyLong_Check(arg))
235235
n = PyNumber_Absolute(arg);
236236
else {
237-
long hash = PyObject_Hash(arg);
237+
Py_ssize_t hash = PyObject_Hash(arg);
238238
if (hash == -1)
239239
goto Done;
240-
n = PyLong_FromUnsignedLong((unsigned long)hash);
240+
n = PyLong_FromSsize_t(hash);
241241
}
242242
if (n == NULL)
243243
goto Done;

0 commit comments

Comments
 (0)