[util] make NONE compare equal to the native None

This commit is contained in:
Mike Fährmann
2025-06-22 19:50:21 +02:00
parent 2cbc5cc454
commit ce4d78e8e3
2 changed files with 8 additions and 2 deletions

View File

@@ -681,10 +681,10 @@ class CustomNone():
raise StopIteration
def __eq__(self, other):
return self is other
return other is self or other is None
def __ne__(self, other):
return self is not other
return other is not self and other is not None
__lt__ = true
__le__ = true

View File

@@ -882,6 +882,12 @@ value = 123
obj = util.NONE
self.assertFalse(obj)
self.assertEqual(obj, obj)
self.assertEqual(obj, None)
self.assertNotEqual(obj, False)
self.assertNotEqual(obj, 0)
self.assertNotEqual(obj, "")
self.assertEqual(len(obj), 0)
self.assertEqual(int(obj), 0)
self.assertEqual(hash(obj), 0)