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-boxed.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-boxed.c')
| -rw-r--r-- | gi/pygi-boxed.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/gi/pygi-boxed.c b/gi/pygi-boxed.c index 6832a7b6..6a06eccd 100644 --- a/gi/pygi-boxed.c +++ b/gi/pygi-boxed.c @@ -226,8 +226,11 @@ static PyMethodDef boxed_methods[] = { { NULL, NULL, 0 } }; -void -_pygi_boxed_register_types (PyObject *m) +/** + * Returns 0 on success, or -1 and sets an exception. + */ +int +pygi_boxed_register_types (PyObject *m) { Py_TYPE(&PyGIBoxed_Type) = &PyType_Type; PyGIBoxed_Type.tp_base = &PyGBoxed_Type; @@ -238,8 +241,13 @@ _pygi_boxed_register_types (PyObject *m) PyGIBoxed_Type.tp_getset = pygi_boxed_getsets; PyGIBoxed_Type.tp_methods = boxed_methods; - if (PyType_Ready (&PyGIBoxed_Type)) - return; - if (PyModule_AddObject (m, "Boxed", (PyObject *) &PyGIBoxed_Type)) - return; + if (PyType_Ready (&PyGIBoxed_Type) < 0) + return -1; + Py_INCREF ((PyObject *) &PyGIBoxed_Type); + if (PyModule_AddObject (m, "Boxed", (PyObject *) &PyGIBoxed_Type) < 0) { + Py_DECREF ((PyObject *) &PyGIBoxed_Type); + return -1; + } + + return 0; } |
