From 76664eb31199b9c79de673ded807770617403132 Mon Sep 17 00:00:00 2001 From: Yoni Lavi Date: Wed, 16 Nov 2022 09:12:26 +0200 Subject: [PATCH 1/2] 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 a499cb32b22f58..cf5a529af3d0a5 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 0xFCA86420; +} + 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 */ From a1cbd39e29dd860aef3f0c38b2f1b2b40eaa8c6f Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 10 Dec 2022 20:00:14 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022-12-10-20-00-13.gh-issue-99540.ZZZHeP.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-12-10-20-00-13.gh-issue-99540.ZZZHeP.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-12-10-20-00-13.gh-issue-99540.ZZZHeP.rst b/Misc/NEWS.d/next/Core and Builtins/2022-12-10-20-00-13.gh-issue-99540.ZZZHeP.rst new file mode 100644 index 00000000000000..ae043f3aba55e8 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-12-10-20-00-13.gh-issue-99540.ZZZHeP.rst @@ -0,0 +1 @@ +``None`` now hashes to a constant value. This is not a requirements change.