mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 20:50:25 +08:00
#345, cvmat() now caught and exception raised
This commit is contained in:
parent
26b7ed6901
commit
8bcdb56ca9
@ -380,7 +380,9 @@ static int is_iplimage(PyObject *o)
|
||||
static void cvmat_dealloc(PyObject *self)
|
||||
{
|
||||
cvmat_t *pc = (cvmat_t*)self;
|
||||
if (pc->data) {
|
||||
Py_DECREF(pc->data);
|
||||
}
|
||||
cvFree(&pc->a);
|
||||
PyObject_Del(self);
|
||||
}
|
||||
@ -656,6 +658,12 @@ static PyTypeObject cvmat_Type = {
|
||||
sizeof(cvmat_t), /*basicsize*/
|
||||
};
|
||||
|
||||
static int illegal_init(PyObject *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
PyErr_SetString(opencv_error, "Cannot create cvmat directly; use CreateMat() instead");
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void cvmat_specials(void)
|
||||
{
|
||||
cvmat_Type.tp_dealloc = cvmat_dealloc;
|
||||
@ -663,6 +671,7 @@ static void cvmat_specials(void)
|
||||
cvmat_Type.tp_repr = cvmat_repr;
|
||||
cvmat_Type.tp_methods = cvmat_methods;
|
||||
cvmat_Type.tp_getset = cvmat_getseters;
|
||||
cvmat_Type.tp_init = illegal_init;
|
||||
}
|
||||
|
||||
static int is_cvmat(PyObject *o)
|
||||
|
@ -342,8 +342,7 @@ class FunctionTests(OpenCVTests):
|
||||
self.assertEqual(m.type, t)
|
||||
self.assertRaises(cv.error, lambda: cv.CreateMat(0, 100, cv.CV_8SC4))
|
||||
self.assertRaises(cv.error, lambda: cv.CreateMat(100, 0, cv.CV_8SC4))
|
||||
# Uncomment when ticket #100 is fixed
|
||||
# self.assertRaises(cv.error, lambda: cv.CreateMat(100, 100, 666666))
|
||||
self.assertRaises(cv.error, lambda: cv.cvmat())
|
||||
|
||||
def test_DrawChessboardCorners(self):
|
||||
im = cv.CreateImage((512,512), cv.IPL_DEPTH_8U, 3)
|
||||
|
Loading…
Reference in New Issue
Block a user