From 048c5f74b61d5e4fa7617ce7c9111c6754bd4409 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 16 Feb 2017 14:42:17 +0100 Subject: [PATCH] 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 --- lang/python/gpgme.i | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i index c7fc14e0..3e89bb11 100644 --- a/lang/python/gpgme.i +++ b/lang/python/gpgme.i @@ -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);