From: JINMEI Tatuya Date: Wed, 6 Jun 2012 18:58:44 +0000 (-0700) Subject: [master] use Py_hash_t for return value of tp_hash, and define it for old vers. X-Git-Tag: trac2351_base~226^2~59^2~7^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3da2b4dd513ce1108f30a2901bdbab9049845d7e;p=thirdparty%2Fkea.git [master] use Py_hash_t for return value of tp_hash, and define it for old vers. 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. --- diff --git a/src/lib/dns/python/name_python.cc b/src/lib/dns/python/name_python.cc index 6758d0e966..c24d24d51b 100644 --- a/src/lib/dns/python/name_python.cc +++ b/src/lib/dns/python/name_python.cc @@ -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(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(pyself); return (LabelSequence(*self->cppobj).getHash(false)); diff --git a/src/lib/dns/python/pydnspp_common.h b/src/lib/dns/python/pydnspp_common.h index 8092b086d4..e9e935977e 100644 --- a/src/lib/dns/python/pydnspp_common.h +++ b/src/lib/dns/python/pydnspp_common.h @@ -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 diff --git a/src/lib/dns/python/rrclass_python.cc b/src/lib/dns/python/rrclass_python.cc index 2c3dae621c..b94dc0231c 100644 --- a/src/lib/dns/python/rrclass_python.cc +++ b/src/lib/dns/python/rrclass_python.cc @@ -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(pyself); return (self->cppobj->getCode());