===Python API===
Make EXPP_setBitfield() PyObject_IsTrue() to evaluate parameter, so boolean-type attribute setters will accept wider range of true/false inputs.
This commit is contained in:
@@ -825,15 +825,7 @@ PyObject *EXPP_getBitfield( void *param, int setting, char type )
|
|||||||
|
|
||||||
int EXPP_setBitfield( PyObject * value, void *param, int setting, char type )
|
int EXPP_setBitfield( PyObject * value, void *param, int setting, char type )
|
||||||
{
|
{
|
||||||
int flag;
|
int flag = PyObject_IsTrue( value );
|
||||||
char errstr[] = "expected TRUE or FALSE (1 or 0)";
|
|
||||||
|
|
||||||
if( !PyInt_CheckExact ( value ) )
|
|
||||||
return EXPP_ReturnIntError( PyExc_TypeError, errstr );
|
|
||||||
|
|
||||||
flag = PyInt_AS_LONG ( value );
|
|
||||||
if( flag != 0 && flag != 1 )
|
|
||||||
return EXPP_ReturnIntError( PyExc_ValueError, errstr );
|
|
||||||
|
|
||||||
switch ( type ) {
|
switch ( type ) {
|
||||||
case 'b':
|
case 'b':
|
||||||
|
|||||||
Reference in New Issue
Block a user