From 253a39fdffc9b3c270ba815d6e60f416a4ee46a7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Aug 2016 18:46:28 +0100 Subject: [PATCH] Fix hash function type checking for older versions of Python Python 2.6 was asserting instead of throwing a Python TypeError. --- Lib/python/builtin.swg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/python/builtin.swg b/Lib/python/builtin.swg index 6085980d4..3dd5bbf95 100644 --- a/Lib/python/builtin.swg +++ b/Lib/python/builtin.swg @@ -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); \