More memory leaks fixed - in IDProp, Bone.head, tail, matrix, ob.DupObjects (my fault...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 26 May 2007 04:39:31 +0000 (04:39 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 26 May 2007 04:39:31 +0000 (04:39 +0000)
Also stopped using Py_BuildValue for strings, ints and floats.

19 files changed:
source/blender/python/api2_2x/Blender.c
source/blender/python/api2_2x/Bone.c
source/blender/python/api2_2x/Effect.c
source/blender/python/api2_2x/Font.c
source/blender/python/api2_2x/IDProp.c
source/blender/python/api2_2x/Image.c
source/blender/python/api2_2x/Ipo.c
source/blender/python/api2_2x/Key.c
source/blender/python/api2_2x/Lamp.c
source/blender/python/api2_2x/Library.c
source/blender/python/api2_2x/Material.c
source/blender/python/api2_2x/Mathutils.c
source/blender/python/api2_2x/Noise.c
source/blender/python/api2_2x/Object.c
source/blender/python/api2_2x/Scene.c
source/blender/python/api2_2x/Text.c
source/blender/python/api2_2x/charRGBA.c
source/blender/python/api2_2x/point.c
source/blender/python/api2_2x/rgbTuple.c

index 1a46ecf0d41479b4b519ec24bdb798e0d3142013..174c2be95a7dbf5f6bba25c41713ae8c05064418 100644 (file)
@@ -528,7 +528,7 @@ static PyObject *Blender_Redraw( PyObject * self, PyObject * args )
                                              "expected int argument (or nothing)" );
        }
 
-       return M_Window_Redraw( self, Py_BuildValue( "(i)", wintype ) );
+       return M_Window_Redraw( self, PyInt_FromLong( (long)wintype ) );
 }
 
 /*****************************************************************************/
index 8795bb7d984aaba0b354ca5ee82f612123b97beb..ad589615b7d4aef75487ef0565a779c7156841a5 100644 (file)
@@ -935,10 +935,10 @@ static int Bone_setName(BPy_Bone *self, PyObject *value, void *closure)
 }
 //------------------------Bone.roll (get)
 static PyObject *Bone_getRoll(BPy_Bone *self, void *closure)
-{
-       return Py_BuildValue("{s:O, s:O}", 
-               "BONESPACE", PyFloat_FromDouble((self->bone->roll * (180/Py_PI))),
-               "ARMATURESPACE", PyFloat_FromDouble((boneRoll_ToArmatureSpace(self->bone) * (180/Py_PI))));
+{      
+       return Py_BuildValue("{s:f, s:f}", 
+               "BONESPACE", self->bone->roll * (180/Py_PI),
+               "ARMATURESPACE", boneRoll_ToArmatureSpace(self->bone) * (180/Py_PI));
 }
 //------------------------Bone.roll (set)
 static int Bone_setRoll(BPy_Bone *self, PyObject *value, void *closure)
@@ -949,9 +949,14 @@ static int Bone_setRoll(BPy_Bone *self, PyObject *value, void *closure)
 //------------------------Bone.head (get)
 static PyObject *Bone_getHead(BPy_Bone *self, void *closure)
 {
-       return Py_BuildValue("{s:O, s:O}", 
-               "BONESPACE", newVectorObject(self->bone->head, 3, Py_WRAP),
-               "ARMATURESPACE", newVectorObject(self->bone->arm_head, 3, Py_WRAP));
+       PyObject *val1 = newVectorObject(self->bone->head, 3, Py_WRAP);
+       PyObject *val2 = newVectorObject(self->bone->arm_head, 3, Py_WRAP);
+       PyObject *ret = Py_BuildValue(
+                       "{s:O, s:O}", "BONESPACE", val1, "ARMATURESPACE", val2);
+       
+       Py_DECREF(val1);
+       Py_DECREF(val2);
+       return ret;
 }
 //------------------------Bone.head (set)
 static int Bone_setHead(BPy_Bone *self, PyObject *value, void *closure)
@@ -962,9 +967,14 @@ static int Bone_setHead(BPy_Bone *self, PyObject *value, void *closure)
 //------------------------Bone.tail (get)
 static PyObject *Bone_getTail(BPy_Bone *self, void *closure)
 {
-    return Py_BuildValue("{s:O, s:O}", 
-               "BONESPACE", newVectorObject(self->bone->tail, 3, Py_WRAP),
-               "ARMATURESPACE", newVectorObject(self->bone->arm_tail, 3, Py_WRAP));
+       PyObject *val1 = newVectorObject(self->bone->tail, 3, Py_WRAP);
+       PyObject *val2 = newVectorObject(self->bone->arm_tail, 3, Py_WRAP);
+       PyObject *ret = Py_BuildValue("{s:O, s:O}", 
+               "BONESPACE", val1, "ARMATURESPACE", val2);
+       
+       Py_DECREF(val1);
+       Py_DECREF(val2);
+       return ret;
 }
 //------------------------Bone.tail (set)
 static int Bone_setTail(BPy_Bone *self, PyObject *value, void *closure)
@@ -1108,9 +1118,15 @@ static int Bone_setChildren(BPy_Bone *self, PyObject *value, void *closure)
 //------------------------Bone.matrix (get)
 static PyObject *Bone_getMatrix(BPy_Bone *self, void *closure)
 {
-    return Py_BuildValue("{s:O, s:O}", 
-               "BONESPACE", newMatrixObject((float*)self->bone->bone_mat, 3,3, Py_WRAP),
-               "ARMATURESPACE", newMatrixObject((float*)self->bone->arm_mat, 4,4, Py_WRAP));
+       PyObject *val1 = newMatrixObject((float*)self->bone->bone_mat, 3,3, Py_WRAP);
+       PyObject *val2 = newMatrixObject((float*)self->bone->arm_mat, 4,4, Py_WRAP);
+       PyObject *ret = Py_BuildValue("{s:O, s:O}", 
+               "BONESPACE", val1, "ARMATURESPACE", val2);
+       Py_DECREF(val1);
+       Py_DECREF(val2);
+       return ret;
+    
+    
 }
 //------------------------Bone.matrix (set)
 static int Bone_setMatrix(BPy_Bone *self, PyObject *value, void *closure)
index 156c3bb26a60bce8d428fc21f443edfa1243f736..1c309ba08519725567176243369dea66c08ac5e9 100644 (file)
@@ -1494,7 +1494,7 @@ static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
        Effect *eff;
        PartEff *paf;
        Particle *pa=0;
-       PyObject  *list, *strand_list, *pyvec;
+       PyObject  *list, *strand_list, *pyvec, *pyvec2;
        float p_time, c_time, vec[3], vec1[3], cfra, m_time, s_time;
        int a;
        short disp=100 ;
@@ -1585,13 +1585,17 @@ static PyObject *Effect_getParticlesLoc( BPy_Effect * self )
                                        }
                                        where_is_particle(paf, pa, s_time, vec);
                                        where_is_particle(paf, pa, p_time, vec1);
-                                       if( PyList_Append( list, Py_BuildValue("[OO]",
-                                                                       newVectorObject(vec, 3, Py_NEW),
-                                                                       newVectorObject(vec1, 3, Py_NEW))) < 0 ) {
+                                       pyvec  = newVectorObject(vec, 3, Py_NEW);
+                                       pyvec2 = newVectorObject(vec1, 3, Py_NEW);
+                                       if( PyList_Append( list, Py_BuildValue("[OO]", pyvec, pyvec2)) < 0 ) {
                                                Py_DECREF( list );
+                                               Py_XDECREF( pyvec );
+                                               Py_XDECREF( pyvec2 );
                                                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
                                                                "Couldn't append item to PyList" );
                                        }
+                                       Py_DECREF( pyvec );
+                                       Py_DECREF( pyvec2 );
                                } else { /* not a vector */
                                        where_is_particle(paf, pa, c_time, vec);
                                        pyvec = newVectorObject(vec, 3, Py_NEW);
index f87e19294ca513bc02461dc6dad3ad215b1410bf..f7e7b2a2c40997a343e7610d0fd564729dcb52e2 100644 (file)
@@ -166,7 +166,7 @@ PyObject *M_Font_Load( PyObject * self, PyObject * args )
        /*create python font*/
        if( !S_ISDIR(BLI_exist(filename_str)) )  {
                tmp= Py_BuildValue("(s)", filename_str);
-               py_font= (BPy_Font *) M_Text3d_LoadFont (self, Py_BuildValue("(s)", filename_str));
+               py_font= (BPy_Font *) M_Text3d_LoadFont (self, tmp);
                Py_DECREF (tmp);
        }
        else
index 3097f51e83940424c396e5ccd2489ff3d7e8dcdf..5372e569d41d29e7f6b74e6e4eae29185bffe2de 100644 (file)
@@ -49,7 +49,7 @@ extern PyTypeObject IDGroup_Iter_Type;
 
 PyObject *IDGroup_repr( BPy_IDProperty *self )
 {
-       return Py_BuildValue( "s", "(ID Property)" );
+       return PyString_FromString( "(ID Property)" );
 }
 
 extern PyTypeObject IDGroup_Type;
@@ -58,11 +58,11 @@ PyObject *BPy_IDGroup_WrapData( ID *id, IDProperty *prop )
 {
        switch ( prop->type ) {
                case IDP_STRING:
-                       return Py_BuildValue( "s", prop->data.pointer );
+                       return PyString_FromString( prop->data.pointer );
                case IDP_INT:
-                       return Py_BuildValue( "i", prop->data.val );
+                       return PyInt_FromLong( (long)prop->data.val );
                case IDP_FLOAT:
-                       return Py_BuildValue( "f", *(float*)(&prop->data.val) );
+                       return PyFloat_FromDouble( (double)(*(float*)(&prop->data.val)) );
                case IDP_GROUP:
                        /*blegh*/
                        {
@@ -140,7 +140,7 @@ int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject *value)
 
 PyObject *BPy_IDGroup_GetName(BPy_IDProperty *self, void *bleh)
 {
-       return Py_BuildValue("s", self->prop->name);
+       return PyString_FromString(self->prop->name);
 }
 
 int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *bleh)
@@ -159,7 +159,7 @@ int BPy_IDGroup_SetName(BPy_IDProperty *self, PyObject *value, void *bleh)
 
 PyObject *BPy_IDGroup_GetType(BPy_IDProperty *self)
 {
-       return Py_BuildValue("i", self->prop->type);
+       return PyInt_FromLong((long)self->prop->type);
 }
 
 static PyGetSetDef BPy_IDGroup_getseters[] = {
@@ -332,13 +332,13 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
 {
        switch (prop->type) {
                case IDP_STRING:
-                       return Py_BuildValue("s", prop->data.pointer);
+                       return PyString_FromString(prop->data.pointer);
                        break;
                case IDP_FLOAT:
-                       return Py_BuildValue("f", *((float*)&prop->data.val));
+                       return PyFloat_FromDouble(*((float*)&prop->data.val));
                        break;
                case IDP_INT:
-                       return Py_BuildValue("i", prop->data.val);
+                       return PyInt_FromLong( (long)prop->data.val );
                        break;
                case IDP_ARRAY:
                {
@@ -351,8 +351,11 @@ PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
                        
                        for (i=0; i<prop->len; i++) {
                                if (prop->subtype == IDP_FLOAT)
-                                       PyList_SetItem(seq, i, Py_BuildValue("f", ((float*)prop->data.pointer)[i]));
-                               else PyList_SetItem(seq, i, Py_BuildValue("i",   ((int*)prop->data.pointer)[i]));
+                                               PyList_SetItem(seq, i,
+                                               PyFloat_FromDouble(((float*)prop->data.pointer)[i]));
+                               
+                               else    PyList_SetItem(seq, i,
+                                               PyInt_FromLong(((int*)prop->data.pointer)[i]));
                        }
                        return seq;
                }
@@ -429,7 +432,7 @@ PyObject *BPy_IDGroup_IterItems(BPy_IDProperty *self)
 
 PyObject *BPy_IDGroup_GetKeys(BPy_IDProperty *self)
 {
-       PyObject *seq = PyList_New(self->prop->len), *st;
+       PyObject *seq = PyList_New(self->prop->len);
        IDProperty *loop;
        int i;
 
@@ -437,10 +440,8 @@ PyObject *BPy_IDGroup_GetKeys(BPy_IDProperty *self)
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
                   "PyList_New() failed" );
                   
-       for (i=0, loop=self->prop->data.group.first; loop; loop=loop->next, i++) {
-               st = Py_BuildValue("s", loop->name);
-               PyList_SetItem(seq, i, st);
-       }
+       for (i=0, loop=self->prop->data.group.first; loop; loop=loop->next, i++)
+               PyList_SetItem(seq, i, PyString_FromString(loop->name));
        
        return seq;
 }
@@ -612,18 +613,18 @@ PyObject *BPy_Wrap_IDProperty(ID *id, IDProperty *prop, IDProperty *parent)
 
 PyObject *IDArray_repr(BPy_IDArray *self)
 {
-       return Py_BuildValue("s", "(ID Array)");
+       return PyString_FromString("(ID Array)");
 }
 
 
 PyObject *BPy_IDArray_GetType(BPy_IDArray *self)
 {
-       return Py_BuildValue("i", self->prop->subtype);
+       return PyInt_FromLong( (long)self->prop->subtype );
 }
 
 PyObject *BPy_IDArray_GetLen(BPy_IDArray *self)
 {
-       return Py_BuildValue("i", self->prop->len);
+       return PyInt_FromLong( (long)self->prop->len );
 }
 
 static PyGetSetDef BPy_IDArray_getseters[] = {
@@ -651,10 +652,10 @@ PyObject *BPy_IDArray_GetItem(BPy_IDArray *self, int index)
 
        switch (self->prop->subtype) {
                case IDP_FLOAT:
-                       return Py_BuildValue("f", ((float*)self->prop->data.pointer)[index]);
+                       return PyFloat_FromDouble( (double)(((float*)self->prop->data.pointer)[index]));
                        break;
                case IDP_INT:
-                       return Py_BuildValue("i", ((int*)self->prop->data.pointer)[index]);
+                       return PyInt_FromLong( (long)((int*)self->prop->data.pointer)[index] );
                        break;
        }
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
@@ -803,20 +804,25 @@ PyObject *IDGroup_Iter_iterself(PyObject *self)
 
 PyObject *IDGroup_Iter_repr(BPy_IDGroup_Iter *self)
 {
-       return Py_BuildValue("s", "(ID Property Group)");
+       return PyString_FromString("(ID Property Group)");
 }
 
 PyObject *BPy_Group_Iter_Next(BPy_IDGroup_Iter *self)
 {
        IDProperty *cur=NULL;
+       PyObject *tmpval;
+       PyObject *ret;
 
        if (self->cur) {
                cur = self->cur;
                self->cur = self->cur->next;
                if (self->mode == IDPROP_ITER_ITEMS) {
-                       return Py_BuildValue("[s, O]", cur->name, BPy_IDGroup_WrapData(self->group->id, cur));
+                       tmpval = BPy_IDGroup_WrapData(self->group->id, cur);
+                       ret = Py_BuildValue("[s, O]", cur->name, tmpval);
+                       Py_DECREF(tmpval);
+                       return ret;
                } else {
-                       return Py_BuildValue("s", cur->name);
+                       return PyString_FromString(cur->name);
                }
        } else {
                return EXPP_ReturnPyObjError( PyExc_StopIteration,
index 7ba3284e04e7b61912dea4af4b02ec393dc8b2a1..63a0c0bda1d17f364b071895825f5596f7755175 100644 (file)
@@ -637,8 +637,7 @@ static PyObject *Image_getMinXY( BPy_Image * self )
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
                                              "couldn't load image data in Blender" );
 
-       attr = Py_BuildValue( "[i,i]", ibuf->xorig,
-                             ibuf->yorig );
+       attr = Py_BuildValue( "[i,i]", ibuf->xorig, ibuf->yorig );
 
        if( attr )
                return attr;
@@ -839,7 +838,7 @@ static PyObject *Image_getDepth( BPy_Image * self )
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
                                              "couldn't load image data in Blender" );
 
-       attr = Py_BuildValue( "h", ibuf->depth );
+       attr = PyInt_FromLong( (long)ibuf->depth );
 
        if( attr )
                return attr;
index 37098400216943b81dbddedc63eb32596e0cec35..8f6e406197620d07d7a1656797aad58a2027b417 100644 (file)
@@ -1255,7 +1255,7 @@ void generate_curveconsts( PyObject* module )
 static PyObject *Ipo_getChannel( BPy_Ipo * self )
 {
        if( self->mtex != -1 )
-               return Py_BuildValue( "h", self->mtex );
+               return PyInt_FromLong( (long)self->mtex );
        Py_RETURN_NONE;
 }
 
index 460bab347a0998079bd47d388030f823d4d25c78..b32f063ffc4956cbb88ab3a02b330c02e82b7fab 100644 (file)
@@ -425,8 +425,7 @@ static PyObject *KeyBlock_getCurval( BPy_KeyBlock * self ) {
 }
 
 static PyObject *KeyBlock_getName( BPy_KeyBlock * self ) {
-       PyObject *name = Py_BuildValue( "s", self->keyblock->name);
-       return name;
+       return PyString_FromString(self->keyblock->name);
 }
 
 static PyObject *KeyBlock_getPos( BPy_KeyBlock * self ){
@@ -442,7 +441,7 @@ static PyObject *KeyBlock_getSlidermax( BPy_KeyBlock * self ){
 }
 
 static PyObject *KeyBlock_getVgroup( BPy_KeyBlock * self ){
-       return Py_BuildValue( "s", self->keyblock->vgroup);
+       return PyString_FromString(self->keyblock->vgroup);
 }
 
 static int KeyBlock_setName( BPy_KeyBlock * self, PyObject * args ){
index 26c3bd39ca6af57d290a1a0fb2c6ece51ef7db02..6be02c45720febc0477ada52160a8229594ad78d 100644 (file)
@@ -1642,7 +1642,7 @@ static PyObject *Lamp_oldsetType( BPy_Lamp * self, PyObject * args )
 
        /* build tuple, call wrapper */
 
-       value = Py_BuildValue( "(i)", type );
+       value = PyInt_FromLong( (long)type );
        error = EXPP_setterWrapper ( (void *)self, value, (setter)Lamp_setType );
        Py_DECREF ( value );
        return error;
@@ -1701,7 +1701,7 @@ static PyObject *Lamp_oldsetMode( BPy_Lamp * self, PyObject * args )
 
        /* build tuple, call wrapper */
 
-       value = Py_BuildValue( "(i)", flag );
+       value = PyInt_FromLong( (long)flag );
        error = EXPP_setterWrapper ( (void *)self, value, (setter)Lamp_setMode );
        Py_DECREF ( value );
        return error;
index 5881c88f654640ebee46ac978440bcabe984a015..495f6eabf446ebfa6c20eec4870ac6f047b32501 100644 (file)
@@ -190,7 +190,7 @@ static PyObject *M_Library_Open( PyObject * self, PyObject * args )
        if( bpy_openlibname )
                PyOS_snprintf( bpy_openlibname, len, "%s", fname1 );
 
-       return Py_BuildValue( "i", 1 );
+       Py_RETURN_TRUE;
 }
 
 /**
@@ -275,16 +275,14 @@ static PyObject *M_Library_Datablocks( PyObject * self, PyObject * args )
                list = PyList_New( BLI_linklist_length( names ) );
                for( l = names; l; l = l->next ) {
                        PyList_SET_ITEM( list, counter,
-                                        Py_BuildValue( "s",
-                                                       ( char * ) l->link ) );
+                                       PyString_FromString( ( char * ) l->link ) );
                        counter++;
                }
                BLI_linklist_free( names, free );       /* free linklist *and* each node's data */
                return list;
        }
 
-       Py_INCREF( Py_None );
-       return Py_None;
+       Py_RETURN_NONE;
 }
 
 /**
index 2f35e9e411f6bccbdcddadf0c70ffe769f5c4ba4..7bf80efa6807f9d4d6fa740a00a0037e2488e438 100644 (file)
@@ -3329,7 +3329,7 @@ static PyObject *Matr_oldsetMode( BPy_Material * self, PyObject * args )
                           "expected nothing, an integer or up to 22 string argument(s)" ) );
        /* build tuple, call wrapper */
 
-       value = Py_BuildValue( "(i)", flag );
+       value = PyInt_FromLong( (long)flag );
        error = EXPP_setterWrapper( (void *)self, value, (setter)Material_setMode );
        Py_DECREF ( value );
        return error;
index b3621eea60e7a57cf379df329d5ac920727e3fce..a21c8bb27eb65c5258394611bd24c157b42cee53 100644 (file)
@@ -1759,7 +1759,7 @@ PyObject *M_Mathutils_RotateEuler(PyObject * self, PyObject * args)
                           "Mathutils.RotateEuler(): expected euler type & float & string");
 
        Euler_Rotate(Eul, Py_BuildValue("fs", angle, axis));
-       return EXPP_incr_ret(Py_None);
+       Py_RETURN_NONE;
 }
 //----------------------------------Mathutils.MatMultVec() --------------
 //COLUMN VECTOR Multiplication (Matrix X Vector)
index 14a254ebcd0cd7e0344401d939b43f0e4c4757c3..821c541b4acad53b1727c2e1ad6da05d9aebd508 100644 (file)
@@ -228,8 +228,9 @@ static PyObject *Noise_noise( PyObject * self, PyObject * args )
        int nb = 1;
        if( !PyArg_ParseTuple( args, "(fff)|i", &x, &y, &z, &nb ) )
                return NULL;
-       return Py_BuildValue( "f",
-                             2.0 * BLI_gNoise( 1.0, x, y, z, 0, nb ) - 1.0 );
+       
+       return PyFloat_FromDouble(
+                       (double)(2.0 * BLI_gNoise( 1.0, x, y, z, 0, nb ) - 1.0) );
 }
 
 /*-------------------------------------------------------------------------*/
@@ -290,7 +291,7 @@ static PyObject *Noise_turbulence( PyObject * self, PyObject * args )
        if( !PyArg_ParseTuple
            ( args, "(fff)ii|iff", &x, &y, &z, &oct, &hd, &nb, &as, &fs ) )
                return NULL;
-       return Py_BuildValue( "f", turb( x, y, z, oct, hd, nb, as, fs ) );
+       return PyFloat_FromDouble( (double)turb( x, y, z, oct, hd, nb, as, fs ) );
 }
 
 /*--------------------------------------------------------------------------*/
@@ -349,7 +350,7 @@ static PyObject *Noise_fBm( PyObject * self, PyObject * args )
        if( !PyArg_ParseTuple
            ( args, "(fff)fff|i", &x, &y, &z, &H, &lac, &oct, &nb ) )
                return NULL;
-       return Py_BuildValue( "f", mg_fBm( x, y, z, H, lac, oct, nb ) );
+       return PyFloat_FromDouble( (double)mg_fBm( x, y, z, H, lac, oct, nb ) );
 }
 
 /*------------------------------------------------------------------------*/
@@ -361,8 +362,7 @@ static PyObject *Noise_multiFractal( PyObject * self, PyObject * args )
        if( !PyArg_ParseTuple
            ( args, "(fff)fff|i", &x, &y, &z, &H, &lac, &oct, &nb ) )
                return NULL;
-       return Py_BuildValue( "f",
-                             mg_MultiFractal( x, y, z, H, lac, oct, nb ) );
+       return PyFloat_FromDouble( (double)mg_MultiFractal( x, y, z, H, lac, oct, nb ) );
 }
 
 /*------------------------------------------------------------------------*/
@@ -374,7 +374,7 @@ static PyObject *Noise_vlNoise( PyObject * self, PyObject * args )
        if( !PyArg_ParseTuple
            ( args, "(fff)f|ii", &x, &y, &z, &d, &nt1, &nt2 ) )
                return NULL;
-       return Py_BuildValue( "f", mg_VLNoise( x, y, z, d, nt1, nt2 ) );
+       return PyFloat_FromDouble( (double)mg_VLNoise( x, y, z, d, nt1, nt2 ) );
 }
 
 /*-------------------------------------------------------------------------*/
@@ -386,9 +386,9 @@ static PyObject *Noise_heteroTerrain( PyObject * self, PyObject * args )
        if( !PyArg_ParseTuple
            ( args, "(fff)ffff|i", &x, &y, &z, &H, &lac, &oct, &ofs, &nb ) )
                return NULL;
-       return Py_BuildValue( "f",
-                             mg_HeteroTerrain( x, y, z, H, lac, oct, ofs,
-                                               nb ) );
+       
+       return PyFloat_FromDouble(
+                       (double)mg_HeteroTerrain( x, y, z, H, lac, oct, ofs, nb ) );
 }
 
 /*-------------------------------------------------------------------------*/
@@ -401,9 +401,9 @@ static PyObject *Noise_hybridMFractal( PyObject * self, PyObject * args )
            ( args, "(fff)fffff|i", &x, &y, &z, &H, &lac, &oct, &ofs, &gn,
              &nb ) )
                return NULL;
-       return Py_BuildValue( "f",
-                             mg_HybridMultiFractal( x, y, z, H, lac, oct, ofs,
-                                                    gn, nb ) );
+       
+       return PyFloat_FromDouble(
+                       (double)mg_HybridMultiFractal( x, y, z, H, lac, oct, ofs, gn, nb) );
 }
 
 /*------------------------------------------------------------------------*/
@@ -416,9 +416,8 @@ static PyObject *Noise_ridgedMFractal( PyObject * self, PyObject * args )
            ( args, "(fff)fffff|i", &x, &y, &z, &H, &lac, &oct, &ofs, &gn,
              &nb ) )
                return NULL;
-       return Py_BuildValue( "f",
-                             mg_RidgedMultiFractal( x, y, z, H, lac, oct, ofs,
-                                                    gn, nb ) );
+       return PyFloat_FromDouble(
+                       (double)mg_RidgedMultiFractal( x, y, z, H, lac, oct, ofs, gn, nb) );
 }
 
 /*-------------------------------------------------------------------------*/
index c8d42dfa8420ff5516e417cc0572e28e88f365ff..8cd872e9988e73e55d3172b6bdb65edd4a106503 100644 (file)
@@ -2966,6 +2966,7 @@ static int Object_setNLAflagBits ( BPy_Object * self, PyObject * args )
 static PyObject *Object_getDupliObjects( BPy_Object * self )
 {
        Object *ob= self->object;
+       PyObject *pair;
        
        if(ob->transflag & OB_DUPLI) {
                /* before make duplis, update particle for current frame */
@@ -2986,11 +2987,13 @@ static PyObject *Object_getDupliObjects( BPy_Object * self )
                                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
                                                "PyList_New() failed" );
 
-                       for(dupob= duplilist->first, index=0; dupob; dupob= dupob->next, index++)
-                               PyList_SetItem( list, index, Py_BuildValue( "(OO)",
-                                                       Object_CreatePyObject(dupob->ob),
-                                                       newMatrixObject((float*)dupob->mat,4,4,Py_NEW) ) );
-
+                       for(dupob= duplilist->first, index=0; dupob; dupob= dupob->next, index++) {
+                               pair = PyTuple_New( 2 );
+                               
+                               PyTuple_SET_ITEM( pair, 0, Object_CreatePyObject(dupob->ob) );
+                               PyTuple_SET_ITEM( pair, 1, newMatrixObject((float*)dupob->mat,4,4,Py_NEW) );
+                               PyList_SET_ITEM( list, index, pair);
+                       }
                        free_object_duplilist(duplilist);
                        return list;
                }
@@ -4978,7 +4981,7 @@ static PyGetSetDef BPy_Object_getseters[] = {
         (void *)OB_DUPLINOSPEED},
        {"DupObjects",
         (getter)Object_getDupliObjects, (setter)NULL,
-        "Get a list of tuples for object duplicated by dupliframe",
+        "Get a list of tuple pairs (object, matrix), for getting dupli objects",
         NULL},
        {"DupGroup",
         (getter)Object_getDupliGroup, (setter)Object_setDupliGroup,
index 25df96a33bd727893b229bdc3004311c95037759..b692c39152084f23cf1e80792824017227a83e2a 100644 (file)
@@ -1170,7 +1170,7 @@ static PyObject *Scene_play( BPy_Scene * self, PyObject * args )
                areawinset( sa->win );
 
        /* play_anim returns 0 for normal exit or 1 if user canceled it */
-       ret = Py_BuildValue( "i", play_anim( mode ) );
+       ret = PyInt_FromLong( (long)play_anim( mode ) );
 
        if( sa )
                areawinset( oldsa->win );
index ea1f5aeb8f133ca58fa3e5d7f0a0327cd916d634..e106bfea48226427d257481a02b859064be69eeb 100644 (file)
@@ -436,7 +436,7 @@ static PyObject *Text_write( BPy_Text * self, PyObject * args )
 static PyObject *Text_asLines( BPy_Text * self )
 {
        TextLine *line;
-       PyObject *list, *ob;
+       PyObject *list, *tmpstr;
 
        if( !self->text )
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
@@ -450,9 +450,9 @@ static PyObject *Text_asLines( BPy_Text * self )
                                              "couldn't create PyList" );
 
        while( line ) {
-               ob = Py_BuildValue( "s", line->line );
-               PyList_Append( list, ob );
-               Py_DECREF(ob);
+               tmpstr = PyString_FromString( line->line );
+               PyList_Append( list, tmpstr );
+               Py_DECREF(tmpstr);
                line = line->next;
        }
 
index fa00fc0ec468223018145f3328f6c438051267f1..43c9b7772fa9d6ea554887d2fe0d98474549104d 100644 (file)
@@ -243,11 +243,10 @@ PyObject *charRGBA_getCol( BPy_charRGBA * self )
                return EXPP_ReturnPyObjError( PyExc_MemoryError,
                                              "couldn't create PyList" );
 
-       PyList_SET_ITEM( list, 0, Py_BuildValue( "b", *( self->rgba[0] ) ) );
-       PyList_SET_ITEM( list, 1, Py_BuildValue( "b", *( self->rgba[1] ) ) );
-       PyList_SET_ITEM( list, 2, Py_BuildValue( "b", *( self->rgba[2] ) ) );
-       PyList_SET_ITEM( list, 3, Py_BuildValue( "b", *( self->rgba[3] ) ) );
-
+       PyList_SET_ITEM( list, 0, PyInt_FromLong( *(self->rgba[0])) );
+       PyList_SET_ITEM( list, 1, PyInt_FromLong( *(self->rgba[1])) );
+       PyList_SET_ITEM( list, 2, PyInt_FromLong( *(self->rgba[2])) );
+       PyList_SET_ITEM( list, 3, PyInt_FromLong( *(self->rgba[3])) );
        return list;
 }
 
@@ -335,7 +334,7 @@ static PyObject *charRGBASubscript( BPy_charRGBA * self, PyObject * key )
        else
                return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
 
-       return Py_BuildValue( "b", *( self->rgba[i] ) );
+       return PyInt_FromLong( (long)(*self->rgba[i]) );
 }
 
 static int charRGBAAssSubscript( BPy_charRGBA * self, PyObject * key,
@@ -382,7 +381,7 @@ static PyObject *charRGBAItem( BPy_charRGBA * self, int i )
                return EXPP_ReturnPyObjError( PyExc_IndexError,
                                              "array index out of range" );
 
-       return Py_BuildValue( "b", *( self->rgba[i] ) );
+       return PyInt_FromLong( *(self->rgba[i]) );
 }
 
 static PyObject *charRGBASlice( BPy_charRGBA * self, int begin, int end )
index cc6bd3a5342415532be71d656b0e1ccc98cf296a..686a4529d9bf50984a4245d860e26d6d7c1405f2 100644 (file)
@@ -172,7 +172,7 @@ static PyObject *Point_item(PointObject * self, int i)
                return EXPP_ReturnPyObjError(PyExc_IndexError,
                "point[attribute]: array index out of range\n");
 
-       return Py_BuildValue("f", self->coord[i]);
+       return PyFloat_FromDouble( (double)self->coord[i] );
 
 }
 //----------------------------object[]-------------------------
index 8536d641042565c6a65b2d7d99037b87b7e03e2c..cdd05a609172a22cdca21a7bff0f1b60c713b112 100644 (file)
@@ -206,7 +206,7 @@ static PyObject *rgbTuple_getAttr( BPy_rgbTuple * self, char *name )
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
                                                "attribute not found" ) );
 
-       return Py_BuildValue( "f", *( self->rgb[i] ) );
+       return PyFloat_FromDouble( (double)(*( self->rgb[i] )) );
 }
 
 /*****************************************************************************/
@@ -271,7 +271,7 @@ static PyObject *rgbTupleSubscript( BPy_rgbTuple * self, PyObject * key )
        else
                return EXPP_ReturnPyObjError( PyExc_AttributeError, name );
 
-       return Py_BuildValue( "f", *( self->rgb[i] ) );
+       return PyFloat_FromDouble( (double)(*( self->rgb[i] )) );
 }
 
 static int rgbTupleAssSubscript( BPy_rgbTuple * self, PyObject * key,
@@ -316,7 +316,7 @@ static PyObject *rgbTupleItem( BPy_rgbTuple * self, int i )
                return EXPP_ReturnPyObjError( PyExc_IndexError,
                                              "array index out of range" );
 
-       return Py_BuildValue( "f", *( self->rgb[i] ) );
+       return PyFloat_FromDouble( (long)(*( self->rgb[i] )) );
 }
 
 static PyObject *rgbTupleSlice( BPy_rgbTuple * self, int begin, int end )