diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2008-08-17 21:11:51 +0400 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2008-08-17 21:11:51 +0400 |
commit | 7fd701ab583e4352b3d04a58a87981d647c491a1 (patch) | |
tree | 46363d5aee5d0289e43bd80574477a614a11c92a /source | |
parent | f4d682dd2cefd282e659b8d3050ad2f831f5bc7e (diff) |
== BPython API ==
Bug: Draw.Number wasn't properly checking that the initial, min and max values passed to it were numbers. On errors Python would set an error flag that would only be caught later on, masking where the real problem was. Pesky bug...
Reported by André (jaguarandi) on irc, thanks!
PS for bpy devs: PyInt_AsLong returns -1 on error and sets the error flag. With functions like that we need to take special care or not that obvious bugs appear.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/python/api2_2x/Draw.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index 047a035fb8b..bd19a6a6a3e 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -1554,6 +1554,12 @@ static PyObject *Method_Number( PyObject * self, PyObject * args ) UI_METHOD_ERRORCHECK; + if ( !PyNumber_Check(inio) || !PyNumber_Check(mino) || + !PyNumber_Check(maxo) ) { + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected ints or floats for the initial, min and max values" ); + } + but = newbutton( ); if (tip) strncpy(but->tooltip, tip, BPY_MAX_TOOLTIP); block = Get_uiBlock( ); |