X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fbc46b2046e6c2ed4fa94c169b3bd4268a7e1963..409eab506ebe5454e10b7e49da263993e00399ce:/wxPython/src/mac/gdi_wrap.cpp diff --git a/wxPython/src/mac/gdi_wrap.cpp b/wxPython/src/mac/gdi_wrap.cpp index 37f1ce2216..332680d868 100644 --- a/wxPython/src/mac/gdi_wrap.cpp +++ b/wxPython/src/mac/gdi_wrap.cpp @@ -363,15 +363,30 @@ SWIG_CheckUnsignedLongInRange(unsigned long value, const char* type, } +SWIGSTATICINLINE(long) +SWIG_AsLong(PyObject * 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; + } +} + + SWIGSTATICINLINE(unsigned long) 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; } @@ -464,13 +479,6 @@ SWIG_CheckLongInRange(long value, const char* type, } -SWIGSTATICINLINE(long) -SWIG_AsLong(PyObject * obj) -{ - return PyInt_Check(obj) ? PyInt_AsLong(obj) : PyLong_AsLong(obj); -} - - #if INT_MAX != LONG_MAX SWIGSTATICINLINE(int) SWIG_AsInt(PyObject *obj) @@ -778,17 +786,15 @@ wxColour wxDC_GetPixel(wxDC *self,wxPoint const &pt){ SWIGSTATICINLINE(double) SWIG_AsDouble(PyObject *obj) { - double val = (PyFloat_Check(obj)) ? PyFloat_AsDouble(obj) : -#if HAVE_LONG_LONG - ((PyInt_Check(obj)) ? PyInt_AsLong(obj) : PyLong_AsLongLong(obj)); -#else - ((PyInt_Check(obj)) ? PyInt_AsLong(obj) : PyLong_AsLong(obj)); -#endif - if (PyErr_Occurred()) { - PyErr_Clear(); - PyErr_SetString(PyExc_TypeError, "a double is expected"); - } - return val; + if (PyNumber_Check(obj)) + return PyFloat_AsDouble(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; + } }