From 97d3f066bf84218e7bfb66a6a25d665c450e7f3d Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Sun, 8 Jul 2007 21:05:38 +0000 Subject: Work around the deprecation warning of BaseException.message in Python 2.6+ affecting GError exceptions. Fixes #342948. svn path=/trunk/; revision=689 --- gobject/gobjectmodule.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'gobject') diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 20003b9..48b2c24 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -3089,6 +3089,21 @@ bad_gerror: return -2; } +static PyObject * +build_gerror( void ) +{ + PyObject *dict; + PyObject *gerror_class; + dict = PyDict_New(); + /* This is a hack to work around the deprecation warning of + * BaseException.message in Python 2.6+. + * GError has also an "message" attribute. + */ + PyDict_SetItemString(dict, "message", Py_None); + gerror_class = PyErr_NewException("gobject.GError", PyExc_RuntimeError, dict); + Py_DECREF(dict); + return gerror_class; +} static PyObject * _pyg_strv_from_gvalue(const GValue *value) @@ -3491,7 +3506,7 @@ init_gobject(void) pyobject_copy, pyobject_free); - gerror_exc = PyErr_NewException("gobject.GError", PyExc_RuntimeError,NULL); + gerror_exc = build_gerror(); PyDict_SetItemString(d, "GError", gerror_exc); PyGObject_Type.tp_alloc = PyType_GenericAlloc; -- cgit