commit 14352c3e57b7deb3aab73fd4c44e22ec65f93669 Author: Lawrence D'Oliveiro Date: Mon Feb 16 05:56:27 2015 +0000 implement type check on operand of Matrix.__mul__ diff --git a/src/matrix.c b/src/matrix.c index 24f6e4a..0eee7b3 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -97,6 +97,11 @@ matrix_multiply (PycairoMatrix *o, PyObject *args) { static PyObject * matrix_operator_multiply (PycairoMatrix *o, PycairoMatrix *o2) { cairo_matrix_t result; + if (PyObject_IsInstance(o2, &PycairoMatrix_Type) <= 0) + { + PyErr_SetString(PyExc_TypeError, "matrix can only multiply another matrix"); + return NULL; + } /*if*/ cairo_matrix_multiply (&result, &o->matrix, &o2->matrix); return PycairoMatrix_FromMatrix (&result); }