X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4f89f6a36b34749fd9bcad72cb99668bf26ac611..a212b7793ae0f811582b842589b4db0fccf15bf4:/wxPython/contrib/xrc/xrc_wrap.cpp?ds=sidebyside diff --git a/wxPython/contrib/xrc/xrc_wrap.cpp b/wxPython/contrib/xrc/xrc_wrap.cpp index e11dd11403..723abd9834 100644 --- a/wxPython/contrib/xrc/xrc_wrap.cpp +++ b/wxPython/contrib/xrc/xrc_wrap.cpp @@ -330,7 +330,15 @@ SWIG_CheckLongInRange(long value, const char* type, SWIGSTATICINLINE(long) SWIG_AsLong(PyObject * obj) { - return PyInt_Check(obj) ? PyInt_AsLong(obj) : PyLong_AsLong(obj); + if (PyNumber_Check(obj)) + return PyInt_AsLong(obj); + else { + PyObject* errmsg = PyString_FromFormat("Expected number, got %s", + obj->ob_type->tp_name); + PyErr_SetObject(PyExc_TypeError, errmsg); + Py_DECREF(errmsg); + return 0; + } }