small mathutils changes.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 4 Feb 2011 03:39:06 +0000 (03:39 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 4 Feb 2011 03:39:06 +0000 (03:39 +0000)
- fix for returning empty slices (was returning list rather then tuple).
- report invalid type when mathutils_array_parse_fast() fails.

source/blender/python/generic/mathutils.c
source/blender/python/generic/mathutils_color.c
source/blender/python/generic/mathutils_euler.c
source/blender/python/generic/mathutils_matrix.c
source/blender/python/generic/mathutils_quat.c
source/blender/python/generic/mathutils_vector.c

index 854aa4f625eb99627b2697a842e6b61015ae586f..29b64dad1e38cbeb3e93161c5c5724f8eecf682e 100644 (file)
@@ -85,6 +85,7 @@ static char M_Mathutils_doc[] =
 static int mathutils_array_parse_fast(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
 {
        PyObject *value_fast= NULL;
+       PyObject *item;
 
        int i, size;
 
@@ -106,8 +107,8 @@ static int mathutils_array_parse_fast(float *array, int array_min, int array_max
        i= size;
        do {
                i--;
-               if(((array[i]= PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value_fast, i))) == -1.0) && PyErr_Occurred()) {
-                       PyErr_Format(PyExc_ValueError, "%.200s: sequence index %d is not a float", error_prefix, i);
+               if(((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0) && PyErr_Occurred()) {
+                       PyErr_Format(PyExc_ValueError, "%.200s: sequence index %d expected a number, found '%.200s' type, ", error_prefix, i, Py_TYPE(item)->tp_name);
                        Py_DECREF(value_fast);
                        return -1;
                }
index 7a879cea3e07f3540cd9e540abee7eda34086ceb..3906f3e2b3887b780d4924daf53f81b569215e3e 100644 (file)
@@ -280,7 +280,7 @@ static PyObject *Color_subscript(ColorObject *self, PyObject *item)
                        return NULL;
 
                if (slicelength <= 0) {
-                       return PyList_New(0);
+                       return PyTuple_New(0);
                }
                else if (step == 1) {
                        return Color_slice(self, start, stop);
index 10c8700148fdd7fdb757d8a02e6c1600676a34ac..0294cfd72e9cc86bae00304d0decc2f3695e1b1c 100644 (file)
@@ -446,7 +446,7 @@ static PyObject *Euler_subscript(EulerObject *self, PyObject *item)
                        return NULL;
 
                if (slicelength <= 0) {
-                       return PyList_New(0);
+                       return PyTuple_New(0);
                }
                else if (step == 1) {
                        return Euler_slice(self, start, stop);
index bd705791a9c2ebb3bf13088f5fc45ef6b82298ac..9d5dafbf6f8ca73737937c729a0403019e25ac76 100644 (file)
@@ -1553,7 +1553,7 @@ static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item)
                        return NULL;
 
                if (slicelength <= 0) {
-                       return PyList_New(0);
+                       return PyTuple_New(0);
                }
                else if (step == 1) {
                        return Matrix_slice(self, start, stop);
index bc7d80bdfbbc2f4793805b20e60898e344dc7777..1b571742cda0545d82c5aa403eb3e42f8dcdfb5a 100644 (file)
@@ -548,7 +548,7 @@ static PyObject *Quaternion_subscript(QuaternionObject *self, PyObject *item)
                        return NULL;
 
                if (slicelength <= 0) {
-                       return PyList_New(0);
+                       return PyTuple_New(0);
                }
                else if (step == 1) {
                        return Quaternion_slice(self, start, stop);
index 20bb0779af5738a61d25200490ba4402e335101c..ba5cf4bb317b2db50db225b2a9e0f502f1557567 100644 (file)
@@ -1324,7 +1324,7 @@ static PyObject *Vector_subscript(VectorObject* self, PyObject* item)
                        return NULL;
 
                if (slicelength <= 0) {
-                       return PyList_New(0);
+                       return PyTuple_New(0);
                }
                else if (step == 1) {
                        return Vector_slice(self, start, stop);