From 5029a4444a7d62125c83ade29b0c04b5d513a374 Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Sun, 1 Jan 2006 15:50:53 +0000 Subject: [PATCH] Bug fix #3671: Blender.Beztriple.New() did not accept sequences as parameters, even though its error messages suggested it did. Thanks to Yann for the patch (I also added the ability to accept parameters without requiring them to be in a tuple). Also documented the New() function. --- source/blender/python/api2_2x/BezTriple.c | 54 ++++++++++++++--------- source/blender/python/api2_2x/doc/Ipo.py | 11 +++++ 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/source/blender/python/api2_2x/BezTriple.c b/source/blender/python/api2_2x/BezTriple.c index 98e53d2fef8..1e835b3f316 100644 --- a/source/blender/python/api2_2x/BezTriple.c +++ b/source/blender/python/api2_2x/BezTriple.c @@ -136,43 +136,55 @@ PyTypeObject BezTriple_Type = { static PyObject *M_BezTriple_New( PyObject* self, PyObject * args ) { float numbuf[9]; - int status, length; PyObject* in_args = NULL; + int length; - if( !PyArg_ParseTuple( args, "|O", &in_args) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected sequence of 3 or 9 floats or nothing" ); + /* accept list, tuple, or 3 or 9 args (which better be floats) */ + + length = PyTuple_Size( args ); + if( length == 3 || length == 9 ) + in_args = args; + else if( !PyArg_ParseTuple( args, "|O", &in_args) ) + goto TypeError; if( !in_args ) { numbuf[0] = 0.0f; numbuf[1] = 0.0f; numbuf[2] = 0.0f; numbuf[3] = 0.0f; numbuf[4] = 0.0f; numbuf[5] = 0.0f; numbuf[6] = 0.0f; numbuf[7] = 0.0f; numbuf[8] = 0.0f; } else { + int i, length; if( !PySequence_Check( in_args ) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected sequence of 3 or 9 floats or nothing" ); - + goto TypeError; + length = PySequence_Length( in_args ); - if( length == 9 ) - status = PyArg_ParseTuple( in_args, "fffffffff", - &numbuf[0], &numbuf[1], &numbuf[2], - &numbuf[3], &numbuf[4], &numbuf[5], - &numbuf[6], &numbuf[7], &numbuf[8]); - else if( length == 3 ) { - status = PyArg_ParseTuple( in_args, "fff", - &numbuf[0], &numbuf[1], &numbuf[2]); + if( length != 9 && length != 3 ) + goto TypeError; + + for(i=0; i