summaryrefslogtreecommitdiff
path: root/gi/pygi-argument.c
diff options
context:
space:
mode:
Diffstat (limited to 'gi/pygi-argument.c')
-rw-r--r--gi/pygi-argument.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c
index 64602f2..fb798e1 100644
--- a/gi/pygi-argument.c
+++ b/gi/pygi-argument.c
@@ -730,6 +730,7 @@ _pygi_argument_from_object (PyObject *object,
int_ = PYGLIB_PyNumber_Long (object);
if (int_ == NULL) {
+ PyErr_SetString (PyExc_TypeError, "expected int argument");
break;
}
@@ -754,6 +755,7 @@ _pygi_argument_from_object (PyObject *object,
number = PYGLIB_PyNumber_Long (object);
if (number == NULL) {
+ PyErr_SetString (PyExc_TypeError, "expected int argument");
break;
}
@@ -784,6 +786,7 @@ _pygi_argument_from_object (PyObject *object,
number = PYGLIB_PyNumber_Long (object);
if (number == NULL) {
+ PyErr_SetString (PyExc_TypeError, "expected int argument");
break;
}
@@ -806,6 +809,7 @@ _pygi_argument_from_object (PyObject *object,
float_ = PyNumber_Float (object);
if (float_ == NULL) {
+ PyErr_SetString (PyExc_TypeError, "expected float or int argument");
break;
}
@@ -820,6 +824,7 @@ _pygi_argument_from_object (PyObject *object,
float_ = PyNumber_Float (object);
if (float_ == NULL) {
+ PyErr_SetString (PyExc_TypeError, "expected float or int argument");
break;
}
@@ -951,6 +956,16 @@ _pygi_argument_from_object (PyObject *object,
break;
}
+ /* Note, strings are sequences, but we cannot accept them here */
+ if (!PySequence_Check (object) ||
+#if PY_VERSION_HEX < 0x03000000
+ PyString_Check (object) ||
+#endif
+ PyUnicode_Check (object)) {
+ PyErr_SetString (PyExc_TypeError, "expected sequence");
+ break;
+ }
+
length = PySequence_Length (object);
if (length < 0) {
break;
@@ -1097,9 +1112,13 @@ array_success:
result = pygi_struct_foreign_convert_to_g_argument (
object, info, transfer, &arg);
} else if (g_type_is_a (type, G_TYPE_BOXED)) {
- arg.v_pointer = pyg_boxed_get (object, void);
- if (transfer == GI_TRANSFER_EVERYTHING) {
- arg.v_pointer = g_boxed_copy (type, arg.v_pointer);
+ if (pyg_boxed_check (object, type)) {
+ arg.v_pointer = pyg_boxed_get (object, void);
+ if (transfer == GI_TRANSFER_EVERYTHING) {
+ arg.v_pointer = g_boxed_copy (type, arg.v_pointer);
+ }
+ } else {
+ PyErr_Format (PyExc_TypeError, "wrong boxed type");
}
} else if (g_type_is_a (type, G_TYPE_POINTER) ||
g_type_is_a (type, G_TYPE_VARIANT) ||