python: Fix error handling.

* lang/python/gpgme.i (typemap gpgme_key_t[]): Set an error if a
non-key element is discovered.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2017-02-16 14:42:17 +01:00
parent de708e5934
commit 048c5f74b6
No known key found for this signature in database
GPG Key ID: DD1A52F9DA8C9020

View File

@ -137,7 +137,12 @@
/* Following code is from swig's python.swg. */
if ((SWIG_ConvertPtr(pypointer,(void **) &$1[i], $*1_descriptor,SWIG_POINTER_EXCEPTION | $disown )) == -1) {
Py_DECREF(pypointer);
Py_DECREF(pypointer);
PyErr_Format(PyExc_TypeError,
"arg %d: list must contain only gpgme_key_ts, got %s "
"at position %d",
$argnum, pypointer->ob_type->tp_name, i);
free($1);
return NULL;
}
Py_DECREF(pypointer);