PyObject* RRType_toWire(s_RRType* self, PyObject* args);
PyObject* RRType_getCode(s_RRType* self);
PyObject* RRType_richcmp(s_RRType* self, s_RRType* other, int op);
+Py_hash_t RRType_hash(PyObject* pyself);
PyObject* RRType_NSEC3PARAM(s_RRType *self);
PyObject* RRType_DNAME(s_RRType *self);
PyObject* RRType_PTR(s_RRType *self);
return (RRType_createStatic(RRType::ANY()));
}
+Py_hash_t
+RRType_hash(PyObject* pyself) {
+ s_RRType* const self = static_cast<s_RRType*>(pyself);
+ return (self->cppobj->getCode());
+}
} // end anonymous namespace
namespace isc {
NULL, // tp_as_number
NULL, // tp_as_sequence
NULL, // tp_as_mapping
- NULL, // tp_hash
+ RRType_hash, // tp_hash
NULL, // tp_call
RRType_str, // tp_str
NULL, // tp_getattro
self.assertFalse(self.rrtype_1 == 1)
+ def test_hash(self):
+ # Exploiting the knowledge that the hash value is the numeric class
+ # value, we can predict the comparison result.
+ self.assertEqual(hash(RRType.AAAA()), hash(RRType("AAAA")))
+ self.assertEqual(hash(RRType("aaaa")), hash(RRType("AAAA")))
+ self.assertNotEqual(hash(RRType.A()), hash(RRType.NS()))
+ self.assertNotEqual(hash(RRType.AAAA()), hash(RRType("Type65535")))
+
def test_statics(self):
self.assertEqual(RRType("NSEC3PARAM"), RRType.NSEC3PARAM())
self.assertEqual(RRType("DNAME"), RRType.DNAME())