BUG: Handle all possible types of Security object __richcmp__ args

A cython __richcmp__ function isn't allowed to assume that its first
argument is the same as the type of the class to which it belongs, so
our code needs to account for either of its two arguments being of the
wrong type.

Furthermore, the correct way for __richcmp__ to handle when it doesn't
know how to do a comparison is to return NotImplemented.
This commit is contained in:
Jonathan Kamens committed 2015-03-10 20:36:52 -04:00
1 parent c46a3afa3c
commit e19f02a2ec
2 files changed
+21 -10

No files matched your search

+4
View File
@@ -27,3 +27,7 @@ class TestSecurityRichCmp(TestCase):
self.assertFalse(Security(3) > Security(4))
self.assertFalse(Security(4) > Security(4))
self.assertTrue(Security(5) > Security(4))
def test_type_mismatch(self):
self.assertIsNotNone(Security(3) < 'a')
self.assertIsNotNone('a' < Security(3))