From 794c1d10a321e62bdd636e744716b0ae58e2236e Mon Sep 17 00:00:00 2001 From: Yoni Lavi Date: Wed, 16 Nov 2022 09:12:26 +0200 Subject: [PATCH] Constant hash for _PyNone_Type --- Objects/object.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Objects/object.c b/Objects/object.c index a499cb32b22f587..5348bd4dc24b78b 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1638,6 +1638,11 @@ none_bool(PyObject *v) return 0; } +static Py_hash_t none_hash(PyObject *v) +{ + return 0xBADCAB1E; +} + static PyNumberMethods none_as_number = { 0, /* nb_add */ 0, /* nb_subtract */ @@ -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 */