Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorKen Hughes <khughes@pacific.edu>2005-10-04 02:06:16 +0400
committerKen Hughes <khughes@pacific.edu>2005-10-04 02:06:16 +0400
commitb777b23e073193108a656b026e59e44f59c5d392 (patch)
treefbf9e5cb839df6ce8256282444ec507043f29f11 /source
parentb4c85d58f6f7d8d5d5ea62bf508dcd5da812d317 (diff)
Bugfixes for #3102, #3104
- Fix incorrect usage of PySequence_Fast_GET_ITEM() - make EXPP_setFloatRange() convert its argument to float instead of short
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Lamp.c2
-rw-r--r--source/blender/python/api2_2x/Material.c2
-rw-r--r--source/blender/python/api2_2x/Texture.c4
-rw-r--r--source/blender/python/api2_2x/gen_utils.c6
-rw-r--r--source/blender/python/api2_2x/rgbTuple.c29
5 files changed, 23 insertions, 20 deletions
diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c
index 9f684e914ed..89d0eef891c 100644
--- a/source/blender/python/api2_2x/Lamp.c
+++ b/source/blender/python/api2_2x/Lamp.c
@@ -1637,7 +1637,7 @@ static PyObject *Lamp_oldsetMode( BPy_Lamp * self, PyObject * args )
/* check each argument for type, find its value */
for ( i = (short)PyTuple_Size( args ); i-- ; ) {
- name = PyString_AsString ( PySequence_Fast_GET_ITEM( args, i ) );
+ name = PyString_AsString ( PyTuple_GET_ITEM( args, i ) );
if( !name )
return EXPP_ReturnPyObjError ( PyExc_AttributeError,
"expected string argument" );
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index 31f6bb2290c..7a3bbc89f45 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -2945,7 +2945,7 @@ static PyObject *Matr_oldsetMode( BPy_Material * self, PyObject * args )
*/
if ( (PySequence_Size( args ) == 1)
- && PyInt_Check ( PySequence_Fast_GET_ITEM ( args , 0 ) )
+ && PyInt_Check ( PyTuple_GET_ITEM ( args , 0 ) )
&& PyArg_ParseTuple( args, "i", &flag )
&& flag < (MA_RAYMIRROR >> 1) ) {
ok = 1;
diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c
index 9a9dc93af85..30cb602416b 100644
--- a/source/blender/python/api2_2x/Texture.c
+++ b/source/blender/python/api2_2x/Texture.c
@@ -2440,7 +2440,7 @@ static PyObject *Texture_oldsetFlags( BPy_Texture * self, PyObject * args )
for ( i = PyTuple_Size( args ); i-- ; ) {
short thisflag;
- char * name = PyString_AsString( PySequence_Fast_GET_ITEM( args, i ) );
+ char * name = PyString_AsString( PyTuple_GET_ITEM( args, i ) );
if( !name )
return EXPP_ReturnPyObjError ( PyExc_AttributeError,
"expected string argument" );
@@ -2622,7 +2622,7 @@ static PyObject *Texture_oldsetImageFlags( BPy_Texture * self, PyObject * args )
for( i = PyTuple_Size( args ); i-- ; ) {
short thisflag;
- char * name = PyString_AsString( PySequence_Fast_GET_ITEM( args, i ) );
+ char * name = PyString_AsString( PyTuple_GET_ITEM( args, i ) );
if( !name )
return EXPP_ReturnPyObjError ( PyExc_AttributeError,
"expected string argument" );
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c
index 885e7fbf7a0..b88d8e22010 100644
--- a/source/blender/python/api2_2x/gen_utils.c
+++ b/source/blender/python/api2_2x/gen_utils.c
@@ -672,14 +672,14 @@ int EXPP_setFloatRange( PyObject *value, float *param,
float min, float max )
{
char errstr[128];
- short number;
+ float number;
sprintf ( errstr, "expected int argument in [%f,%f]", min, max );
if( !PyNumber_Check ( value ) )
return EXPP_ReturnIntError( PyExc_TypeError, errstr );
- number = (short)PyFloat_AsDouble( value );
+ number = (float)PyFloat_AsDouble( value );
if ( number < min || number > max )
return EXPP_ReturnIntError( PyExc_ValueError, errstr );
@@ -843,7 +843,7 @@ PyObject *EXPP_setterWrapper ( PyObject * self, PyObject * args,
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"expected tuple of one item" );
- error = func ( self, PySequence_Fast_GET_ITEM( args, 0 ), NULL );
+ error = func ( self, PyTuple_GET_ITEM( args, 0 ), NULL );
if ( !error ) {
Py_INCREF( Py_None );
return Py_None;
diff --git a/source/blender/python/api2_2x/rgbTuple.c b/source/blender/python/api2_2x/rgbTuple.c
index 2e228e70661..c498601222f 100644
--- a/source/blender/python/api2_2x/rgbTuple.c
+++ b/source/blender/python/api2_2x/rgbTuple.c
@@ -77,6 +77,7 @@ static PySequenceMethods rgbTupleAsSequence = {
( intintargfunc ) rgbTupleSlice, /* sq_slice */
( intobjargproc ) rgbTupleAssItem, /* sq_ass_item */
( intintobjargproc ) rgbTupleAssSlice, /* sq_ass_slice */
+ 0,0,0
};
/*****************************************************************************/
@@ -149,7 +150,8 @@ PyObject *rgbTuple_getCol( BPy_rgbTuple * self )
int rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args )
{
int ok = 0;
- float r = 0, g = 0, b = 0;
+ int i;
+ float num[3]={0,0,0};
/*
* since rgbTuple_getCol() returns a list, be sure we accept a list
@@ -157,26 +159,27 @@ int rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args )
*/
if( PyObject_Length( args ) == 3 ) {
- if ( PyList_Check ( args ) &&
- PyNumber_Check( PySequence_Fast_GET_ITEM( args, 0 ) ) &&
- PyNumber_Check( PySequence_Fast_GET_ITEM( args, 1 ) ) &&
- PyNumber_Check( PySequence_Fast_GET_ITEM( args, 2 ) ) ) {
- r = (float)PyFloat_AsDouble( PySequence_Fast_GET_ITEM( args, 0 ) );
- g = (float)PyFloat_AsDouble( PySequence_Fast_GET_ITEM( args, 1 ) );
- b = (float)PyFloat_AsDouble( PySequence_Fast_GET_ITEM( args, 2 ) );
+ if ( PyList_Check ( args ) ) {
ok = 1;
+ for( i = 0; i < 3; ++i ) {
+ PyObject *tmp = PyList_GET_ITEM( args, i );
+ if( !PyNumber_Check ( tmp ) ) {
+ ok = 0;
+ break;
+ }
+ num[i] = (float)PyFloat_AsDouble( tmp );
+ }
} else
- ok = PyArg_ParseTuple( args, "fff", &r, &g, &b );
+ ok = PyArg_ParseTuple( args, "fff", &num[0], &num[1], &num[2] );
} else
- ok = PyArg_ParseTuple( args, "|(fff)", &r, &g, &b );
+ ok = PyArg_ParseTuple( args, "|(fff)", &num[0], &num[1], &num[2] );
if( !ok )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected [f,f,f], (f,f,f) or f,f,f as arguments (or nothing)" );
- *( self->rgb[0] ) = EXPP_ClampFloat( r, 0.0, 1.0 );
- *( self->rgb[1] ) = EXPP_ClampFloat( g, 0.0, 1.0 );
- *( self->rgb[2] ) = EXPP_ClampFloat( b, 0.0, 1.0 );
+ for( i = 0; i < 3; ++i )
+ *( self->rgb[i] ) = EXPP_ClampFloat( num[i], 0.0, 1.0 );
return 0;
}