Fix Python 2 builtin tp_hash hashfunc closure regression when using "python:slot"
Closes https://github.com/swig/swig/issues/843
This commit is contained in:
parent
94e7482e48
commit
4963a7f88f
4 changed files with 35 additions and 3 deletions
|
|
@ -13,6 +13,11 @@ SWIGINTERN Py_hash_t
|
|||
SWIG_PyNumber_AsPyHash(PyObject *obj) {
|
||||
Py_hash_t result = -1;
|
||||
#if PY_VERSION_HEX < 0x03020000
|
||||
#if PY_VERSION_HEX < 0x03000000
|
||||
if (PyInt_Check(obj))
|
||||
result = PyInt_AsLong(obj);
|
||||
else
|
||||
#endif
|
||||
if (PyLong_Check(obj))
|
||||
result = PyLong_AsLong(obj);
|
||||
#else
|
||||
|
|
@ -21,7 +26,7 @@ SWIG_PyNumber_AsPyHash(PyObject *obj) {
|
|||
#endif
|
||||
else
|
||||
PyErr_Format(PyExc_TypeError, "Wrong type for hash function");
|
||||
return result;
|
||||
return PyErr_Occurred() ? -1 : result;
|
||||
}
|
||||
|
||||
SWIGINTERN int
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue