Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 50c4000 commit d60cd42Copy full SHA for d60cd42
1 file changed
Modules/_randommodule.c
@@ -228,16 +228,17 @@ random_seed(RandomObject *self, PyObject *args)
228
Py_INCREF(Py_None);
229
return Py_None;
230
}
231
- /* If the arg is an int or long, use its absolute value; else use
232
- * the absolute value of its hash code.
+ /* This algorithm relies on the number being unsigned.
+ * So: if the arg is a PyLong, use its absolute value.
233
+ * Otherwise use its hash value, cast to unsigned.
234
*/
235
if (PyLong_Check(arg))
236
n = PyNumber_Absolute(arg);
237
else {
- Py_ssize_t hash = PyObject_Hash(arg);
238
+ Py_hash_t hash = PyObject_Hash(arg);
239
if (hash == -1)
240
goto Done;
- n = PyLong_FromSsize_t(hash);
241
+ n = PyLong_FromSize_t((size_t)hash);
242
243
if (n == NULL)
244
0 commit comments