From 2abe91752472e501266330b7ca21976046e1973e Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Mon, 9 May 2005 21:14:13 +0000 Subject: Complain if ret is NULL, Fixes #303524. * gobject/pygenum.c (pyg_enum_new): Complain if ret is NULL, Fixes #303524. * gobject/pygflags.c (pyg_flags_new): Change exception format to be consistent with the one in enum --- gobject/pygenum.c | 6 +++++- gobject/pygflags.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gobject/pygenum.c b/gobject/pygenum.c index 5c6bf893..9f32c66a 100644 --- a/gobject/pygenum.c +++ b/gobject/pygenum.c @@ -123,8 +123,12 @@ pyg_enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) g_type_class_unref(eclass); ret = PyDict_GetItem(values, PyInt_FromLong(value)); - Py_INCREF(ret); Py_DECREF(values); + if (ret) + Py_INCREF(ret); + else + PyErr_Format(PyExc_ValueError, "invalid enum value: %ld", value); + return ret; } diff --git a/gobject/pygflags.c b/gobject/pygflags.c index 92f99932..7f052a44 100644 --- a/gobject/pygflags.c +++ b/gobject/pygflags.c @@ -150,7 +150,7 @@ pyg_flags_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) if (ret) Py_INCREF(ret); else - PyErr_SetString(PyExc_ValueError, "invalid flag value"); + PyErr_Format(PyExc_ValueError, "invalid flag value: %ld", value); return ret; } -- cgit v1.2.1