Fix hash function type checking for older versions of Python

Python 2.6 was asserting instead of throwing a Python TypeError.
This commit is contained in:
William S Fulton 2016-08-23 18:46:28 +01:00
commit 253a39fdff

View file

@ -194,7 +194,10 @@ wrapper##_closure(PyObject *a) { \
pyresult = wrapper(a, NULL); \
if (!pyresult) \
return -1; \
result = PyLong_AsLong(pyresult); \
if (!PyLong_Check(pyresult)) \
PyErr_Format(PyExc_TypeError, "Wrong type for hash function");\
else \
result = PyLong_AsLong(pyresult); \
if (PyErr_Occurred()) \
result = -1; \
Py_DECREF(pyresult); \