[Bf-python] Material setName() problem

Bob Holcomb bob_holcomb at hotmail.com
Sun Feb 15 17:00:32 CET 2004


in material setName (and Object setName too, maybe others too) it seems to 
sometimes fail with the error: 


    mat.name=str(material_name)
TypeError: expected string argument


and
    obj=Blender.Object.New(material_name)
TypeError: string expected as argument

Looking at the code for where blender exports the setName feature to python 
for materials and objects it calls the function: 

	if (!PyArg_ParseTuple(args, "s", &name))
		return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string 
argument"));

The problem seems to be the format description "s" which tells python that the 
argument needs to be a string that does NOT end with a null character.  Could 
we add a check that examines the arguments prior calling this function to 
check for and remove a null character if one exists from arguments?  If that 
is not feasable, would changing the argument description from "s" to 
"S" (capital S) fix this condition?  Maybe this is the way it is designed and 
the user should do the check themself.  Comments?

Cheers, 

Bob




More information about the Bf-python mailing list