X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/823f0cfe616bd32f543b6fd7ae5f5ed392b084ac..450d55a035d90e211026a51eb2072d55f5a738a3:/wxPython/contrib/gizmos/gtk/gizmos_wrap.cpp diff --git a/wxPython/contrib/gizmos/gtk/gizmos_wrap.cpp b/wxPython/contrib/gizmos/gtk/gizmos_wrap.cpp index c76c3876e7..f5022e0938 100644 --- a/wxPython/contrib/gizmos/gtk/gizmos_wrap.cpp +++ b/wxPython/contrib/gizmos/gtk/gizmos_wrap.cpp @@ -343,7 +343,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; + } } @@ -451,9 +459,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; } @@ -1181,6 +1189,7 @@ static PyObject *_wrap_EditableListBox_SetStrings(PyObject *self, PyObject *args #else PyObject* str = PyObject_Str(item); #endif + if (PyErr_Occurred()) SWIG_fail; arg2->Add(Py2wxString(str)); Py_DECREF(item); Py_DECREF(str);