Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a5a7cea commit 432117cCopy full SHA for 432117c
2 files changed
Misc/NEWS.d/next/Core and Builtins/2022-12-10-20-00-13.gh-issue-99540.ZZZHeP.rst
@@ -0,0 +1 @@
1
+``None`` now hashes to a constant value. This is not a requirements change.
Objects/object.c
@@ -1641,6 +1641,11 @@ none_bool(PyObject *v)
1641
return 0;
1642
}
1643
1644
+static Py_hash_t none_hash(PyObject *v)
1645
+{
1646
+ return 0xFCA86420;
1647
+}
1648
+
1649
static PyNumberMethods none_as_number = {
1650
0, /* nb_add */
1651
0, /* nb_subtract */
@@ -1692,7 +1697,7 @@ PyTypeObject _PyNone_Type = {
1692
1697
&none_as_number, /*tp_as_number*/
1693
1698
0, /*tp_as_sequence*/
1694
1699
0, /*tp_as_mapping*/
1695
- 0, /*tp_hash */
1700
+ (hashfunc)none_hash,/*tp_hash */
1696
1701
0, /*tp_call */
1702
0, /*tp_str */
1703
0, /*tp_getattro */
0 commit comments