Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-99540: Constant hash for _PyNone_Type to aid reproducibility #99541

Merged
merged 2 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``None`` now hashes to a constant value. This is not a requirements change.
7 changes: 6 additions & 1 deletion Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,11 @@ none_bool(PyObject *v)
return 0;
}

static Py_hash_t none_hash(PyObject *v)
{
return 0xFCA86420;
}

static PyNumberMethods none_as_number = {
0, /* nb_add */
0, /* nb_subtract */
Expand Down Expand Up @@ -1689,7 +1694,7 @@ PyTypeObject _PyNone_Type = {
&none_as_number, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
0, /*tp_hash */
(hashfunc)none_hash,/*tp_hash */
0, /*tp_call */
0, /*tp_str */
0, /*tp_getattro */
Expand Down