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 --- ChangeLog | 8 ++++++++ gobject/gobjectmodule.c | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7017c83..19f40ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-07-08 Johannes Hölzl + + reviewed by: Gustavo Carneiro + + * gobject/gobjectmodule.c (build_gerror, init_gobject): Work + around the deprecation warning of BaseException.message in Python + 2.6+ affecting GError exceptions. Fixes #342948. + 2007-07-07 Gustavo J. A. M. Carneiro * configure.ac: Post-release version bump. 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