From 69223c701760ac3b63b948f3ffac247d9f962d05 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 30 Mar 2004 20:09:28 +0000 Subject: [PATCH] reSWIGged git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26504 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/contrib/activex/activex_wrap.cpp | 10 +++- wxPython/contrib/gizmos/gtk/gizmos_wrap.cpp | 14 ++++-- wxPython/contrib/gizmos/mac/gizmos_wrap.cpp | 14 ++++-- wxPython/contrib/gizmos/msw/gizmos_wrap.cpp | 14 ++++-- .../contrib/glcanvas/gtk/glcanvas_wrap.cpp | 10 +++- .../contrib/glcanvas/mac/glcanvas_wrap.cpp | 10 +++- .../contrib/glcanvas/msw/glcanvas_wrap.cpp | 10 +++- wxPython/contrib/iewin/iewin_wrap.cpp | 10 +++- wxPython/contrib/ogl/gtk/ogl_wrap.cpp | 30 +++++++----- wxPython/contrib/ogl/mac/ogl_wrap.cpp | 30 +++++++----- wxPython/contrib/ogl/msw/ogl_wrap.cpp | 30 +++++++----- wxPython/contrib/stc/stc_wrap.cpp | 10 +++- wxPython/contrib/xrc/xrc_wrap.cpp | 10 +++- wxPython/src/gtk/calendar_wrap.cpp | 14 ++++-- wxPython/src/gtk/controls.py | 4 +- wxPython/src/gtk/controls_wrap.cpp | 14 ++++-- wxPython/src/gtk/core_wrap.cpp | 34 ++++++++------ wxPython/src/gtk/gdi_wrap.cpp | 46 +++++++++++-------- wxPython/src/gtk/grid_wrap.cpp | 34 ++++++++------ wxPython/src/gtk/html_wrap.cpp | 34 ++++++++------ wxPython/src/gtk/misc_wrap.cpp | 34 ++++++++------ wxPython/src/gtk/windows.py | 2 +- wxPython/src/gtk/windows_wrap.cpp | 34 ++++++++------ wxPython/src/gtk/wizard_wrap.cpp | 10 +++- wxPython/src/mac/calendar_wrap.cpp | 14 ++++-- wxPython/src/mac/controls.py | 4 +- wxPython/src/mac/controls_wrap.cpp | 14 ++++-- wxPython/src/mac/core_wrap.cpp | 34 ++++++++------ wxPython/src/mac/gdi_wrap.cpp | 46 +++++++++++-------- wxPython/src/mac/grid_wrap.cpp | 34 ++++++++------ wxPython/src/mac/html_wrap.cpp | 34 ++++++++------ wxPython/src/mac/misc_wrap.cpp | 34 ++++++++------ wxPython/src/mac/windows.py | 2 +- wxPython/src/mac/windows_wrap.cpp | 34 ++++++++------ wxPython/src/mac/wizard_wrap.cpp | 10 +++- wxPython/src/msw/calendar_wrap.cpp | 14 ++++-- wxPython/src/msw/controls.py | 4 +- wxPython/src/msw/controls_wrap.cpp | 14 ++++-- wxPython/src/msw/core_wrap.cpp | 34 ++++++++------ wxPython/src/msw/gdi_wrap.cpp | 46 +++++++++++-------- wxPython/src/msw/grid_wrap.cpp | 34 ++++++++------ wxPython/src/msw/html_wrap.cpp | 34 ++++++++------ wxPython/src/msw/misc_wrap.cpp | 34 ++++++++------ wxPython/src/msw/windows.py | 2 +- wxPython/src/msw/windows_wrap.cpp | 34 ++++++++------ wxPython/src/msw/wizard_wrap.cpp | 10 +++- 46 files changed, 630 insertions(+), 352 deletions(-) diff --git a/wxPython/contrib/activex/activex_wrap.cpp b/wxPython/contrib/activex/activex_wrap.cpp index 7076c339a1..50fd6b3ee3 100644 --- a/wxPython/contrib/activex/activex_wrap.cpp +++ b/wxPython/contrib/activex/activex_wrap.cpp @@ -398,7 +398,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; + } } diff --git a/wxPython/contrib/gizmos/gtk/gizmos_wrap.cpp b/wxPython/contrib/gizmos/gtk/gizmos_wrap.cpp index c76c3876e7..7d2870f862 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; } diff --git a/wxPython/contrib/gizmos/mac/gizmos_wrap.cpp b/wxPython/contrib/gizmos/mac/gizmos_wrap.cpp index f35bafd925..edf223da32 100644 --- a/wxPython/contrib/gizmos/mac/gizmos_wrap.cpp +++ b/wxPython/contrib/gizmos/mac/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; } diff --git a/wxPython/contrib/gizmos/msw/gizmos_wrap.cpp b/wxPython/contrib/gizmos/msw/gizmos_wrap.cpp index 0cb434849e..ad61943e04 100644 --- a/wxPython/contrib/gizmos/msw/gizmos_wrap.cpp +++ b/wxPython/contrib/gizmos/msw/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; } diff --git a/wxPython/contrib/glcanvas/gtk/glcanvas_wrap.cpp b/wxPython/contrib/glcanvas/gtk/glcanvas_wrap.cpp index 610f31d8b4..fe69fdfd60 100644 --- a/wxPython/contrib/glcanvas/gtk/glcanvas_wrap.cpp +++ b/wxPython/contrib/glcanvas/gtk/glcanvas_wrap.cpp @@ -328,7 +328,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; + } } diff --git a/wxPython/contrib/glcanvas/mac/glcanvas_wrap.cpp b/wxPython/contrib/glcanvas/mac/glcanvas_wrap.cpp index 1a4e714f6c..d84670aaed 100644 --- a/wxPython/contrib/glcanvas/mac/glcanvas_wrap.cpp +++ b/wxPython/contrib/glcanvas/mac/glcanvas_wrap.cpp @@ -332,7 +332,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; + } } diff --git a/wxPython/contrib/glcanvas/msw/glcanvas_wrap.cpp b/wxPython/contrib/glcanvas/msw/glcanvas_wrap.cpp index 6a5674405f..c779ee14fc 100644 --- a/wxPython/contrib/glcanvas/msw/glcanvas_wrap.cpp +++ b/wxPython/contrib/glcanvas/msw/glcanvas_wrap.cpp @@ -328,7 +328,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; + } } diff --git a/wxPython/contrib/iewin/iewin_wrap.cpp b/wxPython/contrib/iewin/iewin_wrap.cpp index 6523504c2e..2f7735599e 100644 --- a/wxPython/contrib/iewin/iewin_wrap.cpp +++ b/wxPython/contrib/iewin/iewin_wrap.cpp @@ -310,7 +310,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; + } } diff --git a/wxPython/contrib/ogl/gtk/ogl_wrap.cpp b/wxPython/contrib/ogl/gtk/ogl_wrap.cpp index d9af3ea176..b137351d19 100644 --- a/wxPython/contrib/ogl/gtk/ogl_wrap.cpp +++ b/wxPython/contrib/ogl/gtk/ogl_wrap.cpp @@ -312,17 +312,15 @@ static swig_type_info *swig_types[42]; 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; + } } @@ -369,7 +367,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; + } } diff --git a/wxPython/contrib/ogl/mac/ogl_wrap.cpp b/wxPython/contrib/ogl/mac/ogl_wrap.cpp index 98041aa29f..4e3a462b0e 100644 --- a/wxPython/contrib/ogl/mac/ogl_wrap.cpp +++ b/wxPython/contrib/ogl/mac/ogl_wrap.cpp @@ -312,17 +312,15 @@ static swig_type_info *swig_types[42]; 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; + } } @@ -369,7 +367,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; + } } diff --git a/wxPython/contrib/ogl/msw/ogl_wrap.cpp b/wxPython/contrib/ogl/msw/ogl_wrap.cpp index d9af3ea176..b137351d19 100644 --- a/wxPython/contrib/ogl/msw/ogl_wrap.cpp +++ b/wxPython/contrib/ogl/msw/ogl_wrap.cpp @@ -312,17 +312,15 @@ static swig_type_info *swig_types[42]; 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; + } } @@ -369,7 +367,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; + } } diff --git a/wxPython/contrib/stc/stc_wrap.cpp b/wxPython/contrib/stc/stc_wrap.cpp index 13d9c00f0f..a5e2ad39c7 100644 --- a/wxPython/contrib/stc/stc_wrap.cpp +++ b/wxPython/contrib/stc/stc_wrap.cpp @@ -317,7 +317,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; + } } 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; + } } diff --git a/wxPython/src/gtk/calendar_wrap.cpp b/wxPython/src/gtk/calendar_wrap.cpp index c8139fca08..28d260d46c 100644 --- a/wxPython/src/gtk/calendar_wrap.cpp +++ b/wxPython/src/gtk/calendar_wrap.cpp @@ -310,7 +310,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; + } } @@ -380,9 +388,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; } diff --git a/wxPython/src/gtk/controls.py b/wxPython/src/gtk/controls.py index ca66e9af53..92a7b95f87 100644 --- a/wxPython/src/gtk/controls.py +++ b/wxPython/src/gtk/controls.py @@ -1775,7 +1775,7 @@ class RadioBox(core.Control): long style=RA_HORIZONTAL, Validator validator=DefaultValidator, String name=RadioBoxNameStr) -> RadioBox """ - if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'];del kwargs['point'] newobj = _controls.new_RadioBox(*args, **kwargs) self.this = newobj.this self.thisown = 1 @@ -1921,7 +1921,7 @@ class Slider(core.Control): long style=SL_HORIZONTAL, Validator validator=DefaultValidator, String name=SliderNameStr) -> Slider """ - if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'];del kwargs['point'] newobj = _controls.new_Slider(*args, **kwargs) self.this = newobj.this self.thisown = 1 diff --git a/wxPython/src/gtk/controls_wrap.cpp b/wxPython/src/gtk/controls_wrap.cpp index e0f7043121..f4bc586518 100644 --- a/wxPython/src/gtk/controls_wrap.cpp +++ b/wxPython/src/gtk/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; } diff --git a/wxPython/src/gtk/core_wrap.cpp b/wxPython/src/gtk/core_wrap.cpp index 87c674fdc7..5c9ee17593 100644 --- a/wxPython/src/gtk/core_wrap.cpp +++ b/wxPython/src/gtk/core_wrap.cpp @@ -632,7 +632,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; + } } @@ -673,17 +681,15 @@ PyObject *wxSize_Get(wxSize *self){ 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; + } } @@ -1057,9 +1063,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; } diff --git a/wxPython/src/gtk/gdi_wrap.cpp b/wxPython/src/gtk/gdi_wrap.cpp index f87f20b954..8e46b5aa23 100644 --- a/wxPython/src/gtk/gdi_wrap.cpp +++ b/wxPython/src/gtk/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) @@ -752,17 +760,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; + } } diff --git a/wxPython/src/gtk/grid_wrap.cpp b/wxPython/src/gtk/grid_wrap.cpp index d2c0dc7ad5..dd60ceaddd 100644 --- a/wxPython/src/gtk/grid_wrap.cpp +++ b/wxPython/src/gtk/grid_wrap.cpp @@ -814,7 +814,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; + } } @@ -1127,9 +1135,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; } @@ -1182,17 +1190,15 @@ SWIG_CheckLong(PyObject* obj) 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; + } } diff --git a/wxPython/src/gtk/html_wrap.cpp b/wxPython/src/gtk/html_wrap.cpp index f56340939d..ec00556a57 100644 --- a/wxPython/src/gtk/html_wrap.cpp +++ b/wxPython/src/gtk/html_wrap.cpp @@ -358,7 +358,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; + } } @@ -565,9 +573,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; } @@ -804,17 +812,15 @@ SWIG_FloatCast(double value) 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; + } } diff --git a/wxPython/src/gtk/misc_wrap.cpp b/wxPython/src/gtk/misc_wrap.cpp index 7e124e06c3..0bc15b6ef7 100644 --- a/wxPython/src/gtk/misc_wrap.cpp +++ b/wxPython/src/gtk/misc_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; + } } @@ -489,9 +497,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; } @@ -1096,17 +1104,15 @@ long wxConfigBase_ReadInt(wxConfigBase *self,wxString const &key,long defaultVal 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; + } } diff --git a/wxPython/src/gtk/windows.py b/wxPython/src/gtk/windows.py index f68a4bb51a..d0c85c2bb9 100644 --- a/wxPython/src/gtk/windows.py +++ b/wxPython/src/gtk/windows.py @@ -683,7 +683,7 @@ class SplitterWindow(core.Window): Constructor. Creates and shows a SplitterWindow. """ - if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'];del kwargs['point'] newobj = _windows.new_SplitterWindow(*args, **kwargs) self.this = newobj.this self.thisown = 1 diff --git a/wxPython/src/gtk/windows_wrap.cpp b/wxPython/src/gtk/windows_wrap.cpp index d7fcd53619..defc860398 100644 --- a/wxPython/src/gtk/windows_wrap.cpp +++ b/wxPython/src/gtk/windows_wrap.cpp @@ -385,7 +385,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; + } } @@ -478,17 +486,15 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { 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; + } } @@ -639,9 +645,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; } diff --git a/wxPython/src/gtk/wizard_wrap.cpp b/wxPython/src/gtk/wizard_wrap.cpp index 060fd7969d..930cc16c51 100644 --- a/wxPython/src/gtk/wizard_wrap.cpp +++ b/wxPython/src/gtk/wizard_wrap.cpp @@ -320,7 +320,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; + } } diff --git a/wxPython/src/mac/calendar_wrap.cpp b/wxPython/src/mac/calendar_wrap.cpp index b665d44a85..9256fb8ca2 100644 --- a/wxPython/src/mac/calendar_wrap.cpp +++ b/wxPython/src/mac/calendar_wrap.cpp @@ -310,7 +310,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; + } } @@ -380,9 +388,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; } diff --git a/wxPython/src/mac/controls.py b/wxPython/src/mac/controls.py index df43f387ca..eea366ffa1 100644 --- a/wxPython/src/mac/controls.py +++ b/wxPython/src/mac/controls.py @@ -1771,7 +1771,7 @@ class RadioBox(core.Control): long style=RA_HORIZONTAL, Validator validator=DefaultValidator, String name=RadioBoxNameStr) -> RadioBox """ - if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'];del kwargs['point'] newobj = _controls.new_RadioBox(*args, **kwargs) self.this = newobj.this self.thisown = 1 @@ -1917,7 +1917,7 @@ class Slider(core.Control): long style=SL_HORIZONTAL, Validator validator=DefaultValidator, String name=SliderNameStr) -> Slider """ - if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'];del kwargs['point'] newobj = _controls.new_Slider(*args, **kwargs) self.this = newobj.this self.thisown = 1 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; } diff --git a/wxPython/src/mac/core_wrap.cpp b/wxPython/src/mac/core_wrap.cpp index c7cdbb4b33..67dcbf7d50 100644 --- a/wxPython/src/mac/core_wrap.cpp +++ b/wxPython/src/mac/core_wrap.cpp @@ -632,7 +632,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; + } } @@ -673,17 +681,15 @@ PyObject *wxSize_Get(wxSize *self){ 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; + } } @@ -1057,9 +1063,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; } 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; + } } diff --git a/wxPython/src/mac/grid_wrap.cpp b/wxPython/src/mac/grid_wrap.cpp index 62d6a4d441..170d4ade2f 100644 --- a/wxPython/src/mac/grid_wrap.cpp +++ b/wxPython/src/mac/grid_wrap.cpp @@ -814,7 +814,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; + } } @@ -1127,9 +1135,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; } @@ -1182,17 +1190,15 @@ SWIG_CheckLong(PyObject* obj) 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; + } } diff --git a/wxPython/src/mac/html_wrap.cpp b/wxPython/src/mac/html_wrap.cpp index 541d2e2ca6..429e2e1c76 100644 --- a/wxPython/src/mac/html_wrap.cpp +++ b/wxPython/src/mac/html_wrap.cpp @@ -358,7 +358,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; + } } @@ -565,9 +573,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; } @@ -804,17 +812,15 @@ SWIG_FloatCast(double value) 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; + } } diff --git a/wxPython/src/mac/misc_wrap.cpp b/wxPython/src/mac/misc_wrap.cpp index eac862b56d..bb07d7543b 100644 --- a/wxPython/src/mac/misc_wrap.cpp +++ b/wxPython/src/mac/misc_wrap.cpp @@ -387,7 +387,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; + } } @@ -486,9 +494,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; } @@ -1094,17 +1102,15 @@ long wxConfigBase_ReadInt(wxConfigBase *self,wxString const &key,long defaultVal 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; + } } diff --git a/wxPython/src/mac/windows.py b/wxPython/src/mac/windows.py index c1068f5218..426fac7223 100644 --- a/wxPython/src/mac/windows.py +++ b/wxPython/src/mac/windows.py @@ -688,7 +688,7 @@ class SplitterWindow(core.Window): Constructor. Creates and shows a SplitterWindow. """ - if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'];del kwargs['point'] newobj = _windows.new_SplitterWindow(*args, **kwargs) self.this = newobj.this self.thisown = 1 diff --git a/wxPython/src/mac/windows_wrap.cpp b/wxPython/src/mac/windows_wrap.cpp index 541a3df50c..ec73671c09 100644 --- a/wxPython/src/mac/windows_wrap.cpp +++ b/wxPython/src/mac/windows_wrap.cpp @@ -385,7 +385,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; + } } @@ -478,17 +486,15 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { 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; + } } @@ -634,9 +640,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; } diff --git a/wxPython/src/mac/wizard_wrap.cpp b/wxPython/src/mac/wizard_wrap.cpp index f1d547f1dc..adea91c279 100644 --- a/wxPython/src/mac/wizard_wrap.cpp +++ b/wxPython/src/mac/wizard_wrap.cpp @@ -320,7 +320,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; + } } diff --git a/wxPython/src/msw/calendar_wrap.cpp b/wxPython/src/msw/calendar_wrap.cpp index c8139fca08..28d260d46c 100644 --- a/wxPython/src/msw/calendar_wrap.cpp +++ b/wxPython/src/msw/calendar_wrap.cpp @@ -310,7 +310,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; + } } @@ -380,9 +388,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; } diff --git a/wxPython/src/msw/controls.py b/wxPython/src/msw/controls.py index be2571c57e..bd1f97dda6 100644 --- a/wxPython/src/msw/controls.py +++ b/wxPython/src/msw/controls.py @@ -1783,7 +1783,7 @@ class RadioBox(core.Control): long style=RA_HORIZONTAL, Validator validator=DefaultValidator, String name=RadioBoxNameStr) -> RadioBox """ - if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'];del kwargs['point'] newobj = _controls.new_RadioBox(*args, **kwargs) self.this = newobj.this self.thisown = 1 @@ -1929,7 +1929,7 @@ class Slider(core.Control): long style=SL_HORIZONTAL, Validator validator=DefaultValidator, String name=SliderNameStr) -> Slider """ - if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'];del kwargs['point'] newobj = _controls.new_Slider(*args, **kwargs) self.this = newobj.this self.thisown = 1 diff --git a/wxPython/src/msw/controls_wrap.cpp b/wxPython/src/msw/controls_wrap.cpp index 0aae7da622..5ee8dfc3c5 100644 --- a/wxPython/src/msw/controls_wrap.cpp +++ b/wxPython/src/msw/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; } diff --git a/wxPython/src/msw/core_wrap.cpp b/wxPython/src/msw/core_wrap.cpp index 753ba86965..a040e889ef 100644 --- a/wxPython/src/msw/core_wrap.cpp +++ b/wxPython/src/msw/core_wrap.cpp @@ -632,7 +632,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; + } } @@ -673,17 +681,15 @@ PyObject *wxSize_Get(wxSize *self){ 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; + } } @@ -1057,9 +1063,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; } diff --git a/wxPython/src/msw/gdi_wrap.cpp b/wxPython/src/msw/gdi_wrap.cpp index 2337f845e2..34429f3931 100644 --- a/wxPython/src/msw/gdi_wrap.cpp +++ b/wxPython/src/msw/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) @@ -753,17 +761,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; + } } diff --git a/wxPython/src/msw/grid_wrap.cpp b/wxPython/src/msw/grid_wrap.cpp index d2c0dc7ad5..dd60ceaddd 100644 --- a/wxPython/src/msw/grid_wrap.cpp +++ b/wxPython/src/msw/grid_wrap.cpp @@ -814,7 +814,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; + } } @@ -1127,9 +1135,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; } @@ -1182,17 +1190,15 @@ SWIG_CheckLong(PyObject* obj) 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; + } } diff --git a/wxPython/src/msw/html_wrap.cpp b/wxPython/src/msw/html_wrap.cpp index f56340939d..ec00556a57 100644 --- a/wxPython/src/msw/html_wrap.cpp +++ b/wxPython/src/msw/html_wrap.cpp @@ -358,7 +358,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; + } } @@ -565,9 +573,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; } @@ -804,17 +812,15 @@ SWIG_FloatCast(double value) 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; + } } diff --git a/wxPython/src/msw/misc_wrap.cpp b/wxPython/src/msw/misc_wrap.cpp index 0eed20e0e5..3e38d3c3f1 100644 --- a/wxPython/src/msw/misc_wrap.cpp +++ b/wxPython/src/msw/misc_wrap.cpp @@ -387,7 +387,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; + } } @@ -486,9 +494,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; } @@ -1086,17 +1094,15 @@ long wxConfigBase_ReadInt(wxConfigBase *self,wxString const &key,long defaultVal 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; + } } diff --git a/wxPython/src/msw/windows.py b/wxPython/src/msw/windows.py index 3742b852a1..4da0354318 100644 --- a/wxPython/src/msw/windows.py +++ b/wxPython/src/msw/windows.py @@ -688,7 +688,7 @@ class SplitterWindow(core.Window): Constructor. Creates and shows a SplitterWindow. """ - if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'];del kwargs['point'] newobj = _windows.new_SplitterWindow(*args, **kwargs) self.this = newobj.this self.thisown = 1 diff --git a/wxPython/src/msw/windows_wrap.cpp b/wxPython/src/msw/windows_wrap.cpp index c8c0689c2f..958f2f1fea 100644 --- a/wxPython/src/msw/windows_wrap.cpp +++ b/wxPython/src/msw/windows_wrap.cpp @@ -385,7 +385,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; + } } @@ -478,17 +486,15 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) { 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; + } } @@ -639,9 +645,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; } diff --git a/wxPython/src/msw/wizard_wrap.cpp b/wxPython/src/msw/wizard_wrap.cpp index 060fd7969d..930cc16c51 100644 --- a/wxPython/src/msw/wizard_wrap.cpp +++ b/wxPython/src/msw/wizard_wrap.cpp @@ -320,7 +320,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; + } } -- 2.45.2