[Bf-python] boolean check bug in Armature_setDrawAxes

Toni Alatalo antont at kyperjokki.fi
Fri Dec 23 03:09:17 CET 2005


hi,

Brandano just reported a segfault on irc, from doing Armature.drawAxes = 1

the current code seems to check if the input is a boolean object, which is 
wrong: it should *evaluate* whether the given object is considered True or 
False according to the Python rules. e.g. "blender" is True, "" is False.

so some time after the freeze is over, this should be replaced with a call to 
PyObject_IsTrue(PyObject *o) (documented in 
http://www.python.org/dev/doc/maint/api/object.html) and the change included 
in the upcoming bugfix release..

this current code does not handle the case where input exists, but is not a 
PyBool type, at all. dunno if the same prob exists in other parts of the api

 //------------------------Armature.drawAxes (setter)
static int Armature_setDrawAxes(BPy_Armature *self, PyObject *value, void 
*closure)
{
	if(value){
		if(PyBool_Check(value)){
			if (value == Py_True){
				self->armature->flag |= ARM_DRAWAXES;
				return 0;
			}else if (value == Py_False){
				self->armature->flag &= ~ARM_DRAWAXES;
				return 0;
			}
		}
	}
	goto AttributeError;

~Toni



More information about the Bf-python mailing list