mirror of
https://github.com/python/cpython.git
synced 2025-11-26 13:22:51 +00:00
gh-99540: Constant hash for _PyNone_Type to aid reproducibility (GH-99541)
Needed for ASLR builds of Python.
This commit is contained in:
parent
a5a7cea202
commit
432117cd1f
2 changed files with 7 additions and 1 deletions
|
|
@ -0,0 +1 @@
|
||||||
|
``None`` now hashes to a constant value. This is not a requirements change.
|
||||||
|
|
@ -1641,6 +1641,11 @@ none_bool(PyObject *v)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Py_hash_t none_hash(PyObject *v)
|
||||||
|
{
|
||||||
|
return 0xFCA86420;
|
||||||
|
}
|
||||||
|
|
||||||
static PyNumberMethods none_as_number = {
|
static PyNumberMethods none_as_number = {
|
||||||
0, /* nb_add */
|
0, /* nb_add */
|
||||||
0, /* nb_subtract */
|
0, /* nb_subtract */
|
||||||
|
|
@ -1692,7 +1697,7 @@ PyTypeObject _PyNone_Type = {
|
||||||
&none_as_number, /*tp_as_number*/
|
&none_as_number, /*tp_as_number*/
|
||||||
0, /*tp_as_sequence*/
|
0, /*tp_as_sequence*/
|
||||||
0, /*tp_as_mapping*/
|
0, /*tp_as_mapping*/
|
||||||
0, /*tp_hash */
|
(hashfunc)none_hash,/*tp_hash */
|
||||||
0, /*tp_call */
|
0, /*tp_call */
|
||||||
0, /*tp_str */
|
0, /*tp_str */
|
||||||
0, /*tp_getattro */
|
0, /*tp_getattro */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue