use ValueError when vector/matrix multiplications sizes are not supported, was using...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 11 Feb 2012 14:27:36 +0000 (14:27 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 11 Feb 2012 14:27:36 +0000 (14:27 +0000)
source/blender/python/mathutils/mathutils_Vector.c
source/tests/bl_pyapi_mathutils.py

index dec701d..765df7a 100644 (file)
@@ -1497,7 +1497,7 @@ int column_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject *vec,
                        vec_cpy[3] = 1.0f;
                }
                else {
-                       PyErr_SetString(PyExc_TypeError,
+                       PyErr_SetString(PyExc_ValueError,
                                        "matrix * vector: "
                                                        "len(matrix.col) and len(vector) must be the same, "
                                        "except for 4x4 matrix * 3D vector.");
index b2e9f27..a37f744 100644 (file)
@@ -111,8 +111,8 @@ class MatrixTesting(unittest.TestCase):
 
         vec = Vector((1, 2))
 
-        self.assertRaises(TypeError, mat1.__mul__, vec)
-        self.assertRaises(ValueError, vec.__mul__, mat1)  # Why are these different?!
+        self.assertRaises(ValueError, mat1.__mul__, vec)
+        self.assertRaises(ValueError, vec.__mul__, mat1)
 
         mat2 = Matrix(((1, 2),
                        (-2, 3)))