summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Granjoux <seb.sfo@free.fr>2007-07-02 17:54:27 +0000
committerJohan Dahlin <johan@src.gnome.org>2007-07-02 17:54:27 +0000
commitd1e9ef6614199ea886f2bb2864410383c00fe6f4 (patch)
treee79aac9361434b11cb957b587ae78ba625a559d7
parente0fc94bfbdae09096f73b4378686a3ec2e8e392a (diff)
downloadpygobject-d1e9ef6614199ea886f2bb2864410383c00fe6f4.tar.gz
pygobject-d1e9ef6614199ea886f2bb2864410383c00fe6f4.tar.xz
pygobject-d1e9ef6614199ea886f2bb2864410383c00fe6f4.zip
reviewed by: Johan Dahlin
2007-07-02 Sebastian Granjoux <seb.sfo@free.fr> reviewed by: Johan Dahlin * gobject/gobjectmodule.c: (pyg_gerror_exception_check): * tests/test_gtype.py: * tests/testhelpermodule.c: (_wrap_test_gerror_exception): Fix a bug in pyg_error_exception_check, add a test, Fixes #449879 svn path=/trunk/; revision=678
-rw-r--r--ChangeLog10
-rw-r--r--gobject/gobjectmodule.c2
-rw-r--r--tests/test_gtype.py13
-rw-r--r--tests/testhelpermodule.c27
4 files changed, 51 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e87c8e..13b5b32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-07-02 Sebastian Granjoux <seb.sfo@free.fr>
+
+ reviewed by: Johan Dahlin
+
+ * gobject/gobjectmodule.c: (pyg_gerror_exception_check):
+ * tests/test_gtype.py:
+ * tests/testhelpermodule.c: (_wrap_test_gerror_exception):
+
+ Fix a bug in pyg_error_exception_check, add a test, Fixes #449879
+
2007-06-17 Gustavo J. A. M. Carneiro <gjc@gnome.org>
* gobject/pygobject.h: Add a flags field to PyGObject; uses
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index 8316a20..bf7b42b 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -3044,7 +3044,7 @@ pyg_gerror_exception_check(GError **error)
PyErr_Print();
return -2;
}
- if (!value || !PyErr_GivenExceptionMatches(type, (PyObject *) &gerror_exc)) {
+ if (!value || !PyErr_GivenExceptionMatches(type, (PyObject *) gerror_exc)) {
PyErr_Restore(type, value, traceback);
PyErr_Print();
return -2;
diff --git a/tests/test_gtype.py b/tests/test_gtype.py
index cbf3e1c..df75ccf 100644
--- a/tests/test_gtype.py
+++ b/tests/test_gtype.py
@@ -3,6 +3,16 @@ import unittest
from gobject import GType
from common import gobject, testhelper
+def raiseGError():
+ err = gobject.GError
+ err.message = "Test conversion between exception and GError"
+ err.code = 1
+ err.domain = ""
+ raise err
+
+def test_raiseGError():
+ testhelper.test_gerror_exception(raiseGError)
+
class GTypeTest(unittest.TestCase):
def checkType(self, expected, *objects):
# First, double check so we get back what we sent
@@ -62,6 +72,9 @@ class GTypeTest(unittest.TestCase):
array = [1, 2, 3, "foo", True, None]
self.assertEqual(array, testhelper.test_value_array(array))
+ def testGError(self):
+ self.assertRaises(gobject.GError, test_raiseGError)
+
# XXX: Flags, Enums
class MyObject(gobject.GObject):
diff --git a/tests/testhelpermodule.c b/tests/testhelpermodule.c
index d35aecc..8d9419e 100644
--- a/tests/testhelpermodule.c
+++ b/tests/testhelpermodule.c
@@ -468,6 +468,32 @@ _wrap_test_value_array(PyObject *self, PyObject *args)
return pyg_value_as_pyobject(value, FALSE);
}
+static PyObject *
+_wrap_test_gerror_exception(PyObject *self, PyObject *args)
+{
+ PyObject *py_method;
+ PyObject *py_args;
+ PyObject *py_ret;
+ GError *err = NULL;
+
+ if (!PyArg_ParseTuple(args, "O", &py_method))
+ return NULL;
+
+ py_args = PyTuple_New(0);
+ py_ret = PyObject_CallObject(py_method, py_args);
+ if (pyg_gerror_exception_check(&err)) {
+ pyg_error_check(&err);
+ return NULL;
+ }
+
+ Py_DECREF(py_method);
+ Py_DECREF(py_args);
+ Py_DECREF(py_ret);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyMethodDef testhelper_functions[] = {
{ "get_test_thread", (PyCFunction)_wrap_get_test_thread, METH_NOARGS },
{ "get_unknown", (PyCFunction)_wrap_get_unknown, METH_NOARGS },
@@ -475,6 +501,7 @@ static PyMethodDef testhelper_functions[] = {
{ "test_g_object_new", (PyCFunction)_wrap_test_g_object_new, METH_NOARGS },
{ "connectcallbacks", (PyCFunction)_wrap_connectcallbacks, METH_VARARGS },
{ "test_value_array", (PyCFunction)_wrap_test_value_array, METH_VARARGS },
+ { "test_gerror_exception", (PyCFunction)_wrap_test_gerror_exception, METH_VARARGS },
{ NULL, NULL }
};