pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/9c3458e05865093dd55d7608810a9d0ef0765978

-b55097560d244c08.css" /> gh-112125: Fix None.__ne__(None) returning NotImplemented instead of … · python/cpython@9c3458e · GitHub
Skip to content

Commit 9c3458e

Browse files
gh-112125: Fix None.__ne__(None) returning NotImplemented instead of False (#112504)
1 parent b449415 commit 9c3458e

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
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_BaseObject_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

Lib/test/test_builtin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,11 @@ def __dir__(self):
627627
# test that object has a __dir__()
628628
self.assertEqual(sorted([].__dir__()), dir([]))
629629

630+
def test___ne__(self):
631+
self.assertFalse(None.__ne__(None))
632+
self.assertTrue(None.__ne__(0))
633+
self.assertTrue(None.__ne__("abc"))
634+
630635
def test_divmod(self):
631636
self.assertEqual(divmod(12, 7), (1, 5))
632637
self.assertEqual(divmod(-12, 7), (-2, 2))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix None.__ne__(None) returning NotImplemented instead of False

Objects/object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ PyTypeObject _PyNone_Type = {
20262026
0, /*tp_doc */
20272027
0, /*tp_traverse */
20282028
0, /*tp_clear */
2029-
0, /*tp_richcompare */
2029+
_Py_BaseObject_RichCompare, /*tp_richcompare */
20302030
0, /*tp_weaklistoffset */
20312031
0, /*tp_iter */
20322032
0, /*tp_iternext */

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_BaseObject_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)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy