[pygobject] basictype: always set an error when returning FALSE/NULL
- From: Christoph Reiter <creiter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] basictype: always set an error when returning FALSE/NULL
- Date: Thu, 29 Mar 2018 19:52:03 +0000 (UTC)
commit 85932a856d47127a1486bc43b7f1c016214ef69a
Author: Christoph Reiter <reiter christoph gmail com>
Date: Thu Mar 29 21:23:16 2018 +0200
basictype: always set an error when returning FALSE/NULL
affects _pygi_marshal_from_py_basic_type and _pygi_marshal_to_py_basic_type
gi/pygi-argument.c | 15 ++++-----------
gi/pygi-basictype.c | 8 +++++---
2 files changed, 9 insertions(+), 14 deletions(-)
---
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 4fa970c6..d5c2b65a 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -334,12 +334,6 @@ _pygi_argument_from_object (PyObject *object,
memset(&arg, 0, sizeof(GIArgument));
type_tag = g_type_info_get_tag (type_info);
- /* Ignores cleanup data for now. */
- if (_pygi_marshal_from_py_basic_type (object, &arg, type_tag, transfer, &cleanup_data) ||
- PyErr_Occurred()) {
- return arg;
- }
-
switch (type_tag) {
case GI_TYPE_TAG_ARRAY:
{
@@ -684,7 +678,9 @@ hash_table_release:
/* TODO */
break;
default:
- g_assert_not_reached ();
+ /* Ignores cleanup data for now. */
+ _pygi_marshal_from_py_basic_type (object, &arg, type_tag, transfer, &cleanup_data);
+ break;
}
return arg;
@@ -711,9 +707,6 @@ _pygi_argument_to_object (GIArgument *arg,
PyObject *object = NULL;
type_tag = g_type_info_get_tag (type_info);
- object = _pygi_marshal_to_py_basic_type (arg, type_tag, transfer);
- if (object)
- return object;
switch (type_tag) {
case GI_TYPE_TAG_VOID:
@@ -1000,7 +993,7 @@ _pygi_argument_to_object (GIArgument *arg,
}
default:
{
- g_assert_not_reached();
+ object = _pygi_marshal_to_py_basic_type (arg, type_tag, transfer);
}
}
diff --git a/gi/pygi-basictype.c b/gi/pygi-basictype.c
index f93e2c5f..ec80e572 100644
--- a/gi/pygi-basictype.c
+++ b/gi/pygi-basictype.c
@@ -813,6 +813,8 @@ _pygi_marshal_from_py_basic_type (PyObject *object, /* in */
return FALSE;
default:
+ PyErr_Format (PyExc_TypeError, "Type tag %d not supported",
+ type_tag);
return FALSE;
}
@@ -986,10 +988,10 @@ _pygi_marshal_to_py_basic_type (GIArgument *arg,
return pygi_filename_to_py (arg->v_string);
default:
- break;
+ PyErr_Format (PyExc_TypeError, "Type tag %d not supported",
+ type_tag);
+ return NULL;
}
-
- return NULL;
}
PyObject *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]