Raise an Exception when wrapping a NULL GstIterator.

Original commit message from CVS:
* gst/pygstiterator.c: (pygst_iterator_new):
* testsuite/test_iterator.py:
Raise an Exception when wrapping a NULL GstIterator.
Fixes #566903
This commit is contained in:
Edward Hervey 2009-01-08 12:25:26 +00:00
parent 405b07512a
commit 3b6ab11761
3 changed files with 20 additions and 1 deletions

View file

@ -1,3 +1,10 @@
2009-01-08 Edward Hervey <edward.hervey@collabora.co.uk>
* gst/pygstiterator.c: (pygst_iterator_new):
* testsuite/test_iterator.py:
Raise an Exception when wrapping a NULL GstIterator.
Fixes #566903
2009-01-05 Alessandro Decina <alessandro.decina@collabora.co.uk>
patch by: Vincent GENIEUX <mutex at runbox dot com>

View file

@ -147,6 +147,11 @@ pygst_iterator_new (GstIterator * iter)
{
PyGstIterator *self;
if (iter == NULL) {
PyErr_SetString (PyExc_TypeError, "Invalid GstIterator (NULL)");
return NULL;
}
self = PyObject_NEW (PyGstIterator, &PyGstIterator_Type);
self->iter = iter;
GST_DEBUG ("self:%p , iterator:%p, type:%lu",

View file

@ -107,4 +107,11 @@ class IteratorTest(TestCase):
break
else:
raise AssertionError
def testInvalidIterator(self):
p = gst.Pad("p", gst.PAD_SRC)
# The C function will return NULL, we should
# therefore have an exception raised
self.assertRaises(TypeError, p.iterate_internal_links)
del p