[Bf-python] boolean check bug in Armature_setDrawAxes

Gilbert, Joseph T. jgilbert at tigr.ORG
Fri Dec 23 16:45:15 CET 2005


Couple things:
1.There have been a number of ways to parse Boolean values in the api
and I think this is something else that needs overhaul for the 2.40 api.
Lets add this to the wiki.
2. PyObject_IsTrue evaluates any positive integer as true. It is equally
valid using PyObject_IsTrue to write Armature.drawAxes = 500. Therefore
I don't see it as 'wrong' that the user pass True/False to a Boolean
method and not an integer.
3. The seqfault is a big problem and needs to be fixed. Brandano it
would nice of you to submit this as a bug to the tracker so we can get
it fixed asap.

-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Toni
Alatalo
Sent: Thursday, December 22, 2005 9:09 PM
To: Blender Foundation Python list
Subject: [Bf-python] boolean check bug in Armature_setDrawAxes

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
_______________________________________________
Bf-python mailing list
Bf-python at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-python



More information about the Bf-python mailing list