]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] use Py_hash_t for return value of tp_hash, and define it for old vers.
authorJINMEI Tatuya <jinmei@isc.org>
Wed, 6 Jun 2012 18:58:44 +0000 (11:58 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Wed, 6 Jun 2012 18:58:44 +0000 (11:58 -0700)
The previous code (using long) caused build failure on Solaris.

Python 3.2 changed the return type of internal hash API:
http://docs.python.org/py3k/c-api/object.html#PyObject_Hash

from long to Py_hash_t and solaris seems to be more strict about the
difference of these types.

this patch is a bit ad hoc (define it for older python versions
referring to PY_MINOR_VERSION) but I thought that's the best way for
an urgent care fix.  I'll create a ticket for a cleaner solution.

src/lib/dns/python/name_python.cc
src/lib/dns/python/pydnspp_common.h
src/lib/dns/python/rrclass_python.cc

index 6758d0e96680aadb7351a102016640529542ccb3..c24d24d51b1d7f05a2390839778eb058b38580af 100644 (file)
@@ -115,7 +115,7 @@ PyObject* Name_reverse(s_Name* self);
 PyObject* Name_concatenate(s_Name* self, PyObject* args);
 PyObject* Name_downcase(s_Name* self);
 PyObject* Name_isWildCard(s_Name* self);
-long Name_hash(PyObject* py_self);
+Py_hash_t Name_hash(PyObject* py_self);
 
 PyMethodDef Name_methods[] = {
     { "at", reinterpret_cast<PyCFunction>(Name_at), METH_VARARGS,
@@ -520,7 +520,7 @@ Name_isWildCard(s_Name* self) {
     }
 }
 
-long
+Py_hash_t
 Name_hash(PyObject* pyself) {
     s_Name* const self = static_cast<s_Name*>(pyself);
     return (LabelSequence(*self->cppobj).getHash(false));
index 8092b086d4c42d94fd0da418b28bc95410dbf38a..e9e935977e89f52220ffccd5f5e25ef3b9f17365 100644 (file)
@@ -43,6 +43,11 @@ extern PyObject* po_DNSMessageBADVERS;
 int readDataFromSequence(uint8_t *data, size_t len, PyObject* sequence);
 
 int addClassVariable(PyTypeObject& c, const char* name, PyObject* obj);
+
+// Short term workaround for unifying the return type of tp_hash
+#if PY_MINOR_VERSION < 2
+typedef long Py_hash_t;
+#endif
 } // namespace python
 } // namespace dns
 } // namespace isc
index 2c3dae621cc5b9c08da46d5aab3af7c40c8ba028..b94dc0231cce08a76263b4d468c8f5c247bf9825 100644 (file)
@@ -52,7 +52,7 @@ PyObject* RRClass_str(PyObject* self);
 PyObject* RRClass_toWire(s_RRClass* self, PyObject* args);
 PyObject* RRClass_getCode(s_RRClass* self);
 PyObject* RRClass_richcmp(s_RRClass* self, s_RRClass* other, int op);
-long RRClass_hash(PyObject* pyself);
+Py_hash_t RRClass_hash(PyObject* pyself);
 
 // Static function for direct class creation
 PyObject* RRClass_IN(s_RRClass *self);
@@ -265,7 +265,7 @@ PyObject* RRClass_ANY(s_RRClass*) {
     return (RRClass_createStatic(RRClass::ANY()));
 }
 
-long
+Py_hash_t
 RRClass_hash(PyObject* pyself) {
     s_RRClass* const self = static_cast<s_RRClass*>(pyself);
     return (self->cppobj->getCode());