diff options
| author | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2007-07-08 21:05:38 +0000 |
|---|---|---|
| committer | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2007-07-08 21:05:38 +0000 |
| commit | 97d3f066bf84218e7bfb66a6a25d665c450e7f3d (patch) | |
| tree | f0cb1b58b39e6421a1d7e293d074308c0a17b76b /gobject | |
| parent | a7a0a56ea05b494c8c998c337f0cf9a7264a25b4 (diff) | |
| download | pygobject-97d3f066bf84218e7bfb66a6a25d665c450e7f3d.tar.gz pygobject-97d3f066bf84218e7bfb66a6a25d665c450e7f3d.tar.xz pygobject-97d3f066bf84218e7bfb66a6a25d665c450e7f3d.zip | |
Work around the deprecation warning of BaseException.message in Python 2.6+ affecting GError exceptions. Fixes #342948.
svn path=/trunk/; revision=689
Diffstat (limited to 'gobject')
| -rw-r--r-- | gobject/gobjectmodule.c | 17 |
1 files changed, 16 insertions, 1 deletions
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; |
