X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e35a624d40a71780ac19de2839f9e05007c0fe6c..409eab506ebe5454e10b7e49da263993e00399ce:/wxPython/src/mac/controls_wrap.cpp diff --git a/wxPython/src/mac/controls_wrap.cpp b/wxPython/src/mac/controls_wrap.cpp index b08e47d7d8..a24f18a2f7 100644 --- a/wxPython/src/mac/controls_wrap.cpp +++ b/wxPython/src/mac/controls_wrap.cpp @@ -386,7 +386,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; + } } @@ -529,9 +537,9 @@ SWIG_AsUnsignedLong(PyObject * obj) if (PyLong_Check(obj)) { return PyLong_AsUnsignedLong(obj); } else { - long i = PyInt_AsLong(obj); + long i = SWIG_AsLong(obj); if ( !PyErr_Occurred() && (i < 0)) { - PyErr_SetString(PyExc_TypeError, "negative value for unsigned type"); + PyErr_SetString(PyExc_TypeError, "negative value received for unsigned type"); } return i; }