[pygobject/foreign-cairo-fix: 1/2] foreign-cairo: add error handling for the pygobject API initialization
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/foreign-cairo-fix: 1/2] foreign-cairo: add error handling for the pygobject API initialization
- Date: Mon, 17 Sep 2018 17:45:22 +0000 (UTC)
commit ff682293f4a36f6c5340f2255e346925f5e8bc8c
Author: Christoph Reiter <reiter christoph gmail com>
Date: Mon Sep 17 19:35:00 2018 +0200
foreign-cairo: add error handling for the pygobject API initialization
I can fail in case it's called at the wrong point in pygobject's own
module init phase, which is what I tried.
gi/pygi-foreign-cairo.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/gi/pygi-foreign-cairo.c b/gi/pygi-foreign-cairo.c
index c398cb72..718f9a0f 100644
--- a/gi/pygi-foreign-cairo.c
+++ b/gi/pygi-foreign-cairo.c
@@ -539,6 +539,8 @@ cairo_matrix_release (GIBaseInfo *base_info,
static PyMethodDef _gi_cairo_functions[] = { {0,} };
PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
{
+ PyObject *gobject_mod;
+
#if PY_VERSION_HEX < 0x03000000
Pycairo_IMPORT;
#else
@@ -548,7 +550,10 @@ PYGLIB_MODULE_START(_gi_cairo, "_gi_cairo")
if (Pycairo_CAPI == NULL)
return PYGLIB_MODULE_ERROR_RETURN;
- pygobject_init (3, 13, 2);
+ gobject_mod = pygobject_init (3, 13, 2);
+ if (gobject_mod == NULL)
+ return PYGLIB_MODULE_ERROR_RETURN;
+ Py_DECREF (gobject_mod);
pygi_register_foreign_struct ("cairo",
"Matrix",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]