Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 432117c

Browse files
authored
gh-99540: Constant hash for _PyNone_Type to aid reproducibility (GH-99541)
Needed for ASLR builds of Python.
1 parent a5a7cea commit 432117c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``None`` now hashes to a constant value. This is not a requirements change.

Objects/object.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,11 @@ none_bool(PyObject *v)
16411641
return 0;
16421642
}
16431643

1644+
static Py_hash_t none_hash(PyObject *v)
1645+
{
1646+
return 0xFCA86420;
1647+
}
1648+
16441649
static PyNumberMethods none_as_number = {
16451650
0, /* nb_add */
16461651
0, /* nb_subtract */
@@ -1692,7 +1697,7 @@ PyTypeObject _PyNone_Type = {
16921697
&none_as_number, /*tp_as_number*/
16931698
0, /*tp_as_sequence*/
16941699
0, /*tp_as_mapping*/
1695-
0, /*tp_hash */
1700+
(hashfunc)none_hash,/*tp_hash */
16961701
0, /*tp_call */
16971702
0, /*tp_str */
16981703
0, /*tp_getattro */

0 commit comments

Comments
 (0)