diff options
| -rw-r--r-- | lang/python/helpers.c | 20 | 
1 files changed, 20 insertions, 0 deletions
| diff --git a/lang/python/helpers.c b/lang/python/helpers.c index 7e1c1c34..5c620e6b 100644 --- a/lang/python/helpers.c +++ b/lang/python/helpers.c @@ -1,4 +1,5 @@  /* +# Copyright (C) 2016 g10 Code GmbH  # Copyright (C) 2004 Igor Belyi <[email protected]>  # Copyright (C) 2002 John Goerzen <[email protected]>  # @@ -41,6 +42,25 @@ void pygpgme_exception_init(void) {    }  } +static PyObject * +pygpgme_raise_exception(gpgme_error_t err) +{ +  PyObject *e; + +  pygpgme_exception_init(); +  if (GPGMEError == NULL) +    return PyErr_Format(PyExc_RuntimeError, "Got gpgme_error_t %d", err); + +  e = PyObject_CallFunction(GPGMEError, "l", (long) err); +  if (e == NULL) +    return NULL; + +  PyErr_SetObject(GPGMEError, e); +  Py_DECREF(e); + +  return NULL;	/* raise */ +} +  gpgme_error_t pygpgme_exception2code(void) {    gpgme_error_t err_status = gpg_error(GPG_ERR_GENERAL);    if (GPGMEError && PyErr_ExceptionMatches(GPGMEError)) { | 
