Skip to content

Commit e15fb81

Browse files
gh-112125: Fix None.__ne__(None) returning NotImplemented instead of False
1 parent 48dfd74 commit e15fb81

File tree

3 files changed

+42
-34
lines changed

3 files changed

+42
-34
lines changed

Include/internal/pycore_typeobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ extern PyObject* _Py_type_getattro_impl(PyTypeObject *type, PyObject *name,
135135
int *suppress_missing_attribute);
136136
extern PyObject* _Py_type_getattro(PyTypeObject *type, PyObject *name);
137137

138+
extern PyObject* _Py_object_tp_richcompare(PyObject* self, PyObject* other, int op);
139+
138140
extern PyObject* _Py_slot_tp_getattro(PyObject *self, PyObject *name);
139141
extern PyObject* _Py_slot_tp_getattr_hook(PyObject *self, PyObject *name);
140142

Objects/object.c

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,40 +2007,40 @@ PyTypeObject _PyNone_Type = {
20072007
"NoneType",
20082008
0,
20092009
0,
2010-
none_dealloc, /*tp_dealloc*/
2011-
0, /*tp_vectorcall_offset*/
2012-
0, /*tp_getattr*/
2013-
0, /*tp_setattr*/
2014-
0, /*tp_as_async*/
2015-
none_repr, /*tp_repr*/
2016-
&none_as_number, /*tp_as_number*/
2017-
0, /*tp_as_sequence*/
2018-
0, /*tp_as_mapping*/
2019-
(hashfunc)none_hash,/*tp_hash */
2020-
0, /*tp_call */
2021-
0, /*tp_str */
2022-
0, /*tp_getattro */
2023-
0, /*tp_setattro */
2024-
0, /*tp_as_buffer */
2025-
Py_TPFLAGS_DEFAULT, /*tp_flags */
2026-
0, /*tp_doc */
2027-
0, /*tp_traverse */
2028-
0, /*tp_clear */
2029-
0, /*tp_richcompare */
2030-
0, /*tp_weaklistoffset */
2031-
0, /*tp_iter */
2032-
0, /*tp_iternext */
2033-
0, /*tp_methods */
2034-
0, /*tp_members */
2035-
0, /*tp_getset */
2036-
0, /*tp_base */
2037-
0, /*tp_dict */
2038-
0, /*tp_descr_get */
2039-
0, /*tp_descr_set */
2040-
0, /*tp_dictoffset */
2041-
0, /*tp_init */
2042-
0, /*tp_alloc */
2043-
none_new, /*tp_new */
2010+
none_dealloc, /*tp_dealloc*/
2011+
0, /*tp_vectorcall_offset*/
2012+
0, /*tp_getattr*/
2013+
0, /*tp_setattr*/
2014+
0, /*tp_as_async*/
2015+
none_repr, /*tp_repr*/
2016+
&none_as_number, /*tp_as_number*/
2017+
0, /*tp_as_sequence*/
2018+
0, /*tp_as_mapping*/
2019+
(hashfunc)none_hash, /*tp_hash */
2020+
0, /*tp_call */
2021+
0, /*tp_str */
2022+
0, /*tp_getattro */
2023+
0, /*tp_setattro */
2024+
0, /*tp_as_buffer */
2025+
Py_TPFLAGS_DEFAULT, /*tp_flags */
2026+
0, /*tp_doc */
2027+
0, /*tp_traverse */
2028+
0, /*tp_clear */
2029+
_Py_object_tp_richcompare, /*tp_richcompare */
2030+
0, /*tp_weaklistoffset */
2031+
0, /*tp_iter */
2032+
0, /*tp_iternext */
2033+
0, /*tp_methods */
2034+
0, /*tp_members */
2035+
0, /*tp_getset */
2036+
0, /*tp_base */
2037+
0, /*tp_dict */
2038+
0, /*tp_descr_get */
2039+
0, /*tp_descr_set */
2040+
0, /*tp_dictoffset */
2041+
0, /*tp_init */
2042+
0, /*tp_alloc */
2043+
none_new, /*tp_new */
20442044
};
20452045

20462046
PyObject _Py_NoneStruct = _PyObject_HEAD_INIT(&_PyNone_Type);

Objects/typeobject.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5625,6 +5625,12 @@ object_richcompare(PyObject *self, PyObject *other, int op)
56255625
return res;
56265626
}
56275627

5628+
PyObject*
5629+
_Py_object_tp_richcompare(PyObject* self, PyObject* other, int op)
5630+
{
5631+
return object_richcompare(self, other, op);
5632+
}
5633+
56285634
static PyObject *
56295635
object_get_class(PyObject *self, void *closure)
56305636
{

0 commit comments

Comments
 (0)