diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-03-23 16:03:02 +0100 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-03-23 16:03:02 +0100 |
commit | 7b65bc99cf8e399c9b468291b3e89f4c87f99f87 (patch) | |
tree | 59495bb0d4eb38cc5959342f26f34288877c7152 /gi/pygi-error.c | |
parent | 9d1891d51968b7c5ac7928df0207c1b1e7800728 (diff) | |
download | pygobject-7b65bc99cf8e399c9b468291b3e89f4c87f99f87.tar.gz |
Add error handling to all type init function.
They were all just ignoring errors.
Also change those functions to use the pygi prefix.
Diffstat (limited to 'gi/pygi-error.c')
-rw-r--r-- | gi/pygi-error.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gi/pygi-error.c b/gi/pygi-error.c index eb35991b..4feefc4b 100644 --- a/gi/pygi-error.c +++ b/gi/pygi-error.c @@ -372,19 +372,27 @@ pygerror_to_gvalue (GValue *value, PyObject *pyerror) return -1; } -void +/** + * Returns 0 on success, or -1 and sets an exception. + */ +int pygi_error_register_types (PyObject *module) { PyObject *error_module = PYGLIB_PyImport_ImportModule ("gi._error"); if (!error_module) { - return; + return -1; } /* Stash a reference to the Python implemented gi._error.GError. */ PyGError = PyObject_GetAttrString (error_module, "GError"); + Py_DECREF (error_module); + if (PyGError == NULL) + return -1; pyg_register_gtype_custom (G_TYPE_ERROR, pygerror_from_gvalue, pygerror_to_gvalue); + + return 0; } |