mirror of
https://github.com/python/cpython.git
synced 2024-11-23 18:04:37 +08:00
gh-112125: Fix None.__ne__(None) returning NotImplemented instead of False (#112504)
This commit is contained in:
parent
b449415b2f
commit
9c3458e058
@ -135,6 +135,8 @@ extern PyObject* _Py_type_getattro_impl(PyTypeObject *type, PyObject *name,
|
||||
int *suppress_missing_attribute);
|
||||
extern PyObject* _Py_type_getattro(PyTypeObject *type, PyObject *name);
|
||||
|
||||
extern PyObject* _Py_BaseObject_RichCompare(PyObject* self, PyObject* other, int op);
|
||||
|
||||
extern PyObject* _Py_slot_tp_getattro(PyObject *self, PyObject *name);
|
||||
extern PyObject* _Py_slot_tp_getattr_hook(PyObject *self, PyObject *name);
|
||||
|
||||
|
@ -627,6 +627,11 @@ class BuiltinTest(unittest.TestCase):
|
||||
# test that object has a __dir__()
|
||||
self.assertEqual(sorted([].__dir__()), dir([]))
|
||||
|
||||
def test___ne__(self):
|
||||
self.assertFalse(None.__ne__(None))
|
||||
self.assertTrue(None.__ne__(0))
|
||||
self.assertTrue(None.__ne__("abc"))
|
||||
|
||||
def test_divmod(self):
|
||||
self.assertEqual(divmod(12, 7), (1, 5))
|
||||
self.assertEqual(divmod(-12, 7), (-2, 2))
|
||||
|
@ -0,0 +1 @@
|
||||
Fix None.__ne__(None) returning NotImplemented instead of False
|
@ -2026,7 +2026,7 @@ PyTypeObject _PyNone_Type = {
|
||||
0, /*tp_doc */
|
||||
0, /*tp_traverse */
|
||||
0, /*tp_clear */
|
||||
0, /*tp_richcompare */
|
||||
_Py_BaseObject_RichCompare, /*tp_richcompare */
|
||||
0, /*tp_weaklistoffset */
|
||||
0, /*tp_iter */
|
||||
0, /*tp_iternext */
|
||||
|
@ -5625,6 +5625,12 @@ object_richcompare(PyObject *self, PyObject *other, int op)
|
||||
return res;
|
||||
}
|
||||
|
||||
PyObject*
|
||||
_Py_BaseObject_RichCompare(PyObject* self, PyObject* other, int op)
|
||||
{
|
||||
return object_richcompare(self, other, op);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
object_get_class(PyObject *self, void *closure)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user