[Pkg-gnupg-commit] [gpgme] 338/412: python: Fix types and error handling.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu Sep 22 21:27:15 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gpgme.
commit 4abff7d750a1abf5b388a4c87ec321fc3e4aed10
Author: Justus Winter <justus at g10code.com>
Date: Tue Sep 13 13:25:15 2016 +0200
python: Fix types and error handling.
* lang/python/helpers.c (_pyme_edit_cb): Drop the const.
(_pyme_assuan_{data,inquire,status}_cb): Fix error handling.
Signed-off-by: Justus Winter <justus at g10code.com>
---
lang/python/helpers.c | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/lang/python/helpers.c b/lang/python/helpers.c
index 6e63c97..5b13fee 100644
--- a/lang/python/helpers.c
+++ b/lang/python/helpers.c
@@ -692,7 +692,7 @@ gpgme_error_t _pyme_edit_cb(void *opaque, gpgme_status_code_t status,
} else {
if (fd>=0 && retval && PyUnicode_Check(retval)) {
PyObject *encoded = NULL;
- const char *buffer;
+ char *buffer;
Py_ssize_t size;
encoded = PyUnicode_AsUTF8String(retval);
@@ -999,7 +999,10 @@ _pyme_assuan_data_cb (void *hook, const void *data, size_t datalen)
py_data = PyBytes_FromStringAndSize(data, datalen);
if (py_data == NULL)
- return NULL; /* raise */
+ {
+ err = _pyme_exception2code();
+ goto leave;
+ }
retval = PyObject_CallFunctionObjArgs(func, py_data, NULL);
if (PyErr_Occurred())
@@ -1033,23 +1036,29 @@ _pyme_assuan_inquire_cb (void *hook, const char *name, const char *args,
py_name = PyUnicode_FromString(name);
if (py_name == NULL)
- return NULL; /* raise */
+ {
+ err = _pyme_exception2code();
+ goto leave;
+ }
py_args = PyUnicode_FromString(args);
if (py_args == NULL)
- return NULL; /* raise */
+ {
+ err = _pyme_exception2code();
+ goto leave;
+ }
retval = PyObject_CallFunctionObjArgs(func, py_name, py_args, NULL);
if (PyErr_Occurred())
err = _pyme_exception2code();
- Py_DECREF(py_name);
- Py_DECREF(py_args);
Py_XDECREF(retval);
/* FIXME: Returning data is not yet implemented. */
- r_data = NULL;
+ *r_data = NULL;
leave:
+ Py_XDECREF(py_name);
+ Py_XDECREF(py_args);
if (err)
_pyme_stash_callback_exception(self);
return err;
@@ -1074,20 +1083,26 @@ _pyme_assuan_status_cb (void *hook, const char *status, const char *args)
py_status = PyUnicode_FromString(status);
if (py_status == NULL)
- return NULL; /* raise */
+ {
+ err = _pyme_exception2code();
+ goto leave;
+ }
py_args = PyUnicode_FromString(args);
if (py_args == NULL)
- return NULL; /* raise */
+ {
+ err = _pyme_exception2code();
+ goto leave;
+ }
retval = PyObject_CallFunctionObjArgs(func, py_status, py_args, NULL);
if (PyErr_Occurred())
err = _pyme_exception2code();
- Py_DECREF(py_status);
- Py_DECREF(py_args);
Py_XDECREF(retval);
leave:
+ Py_XDECREF(py_status);
+ Py_XDECREF(py_args);
if (err)
_pyme_stash_callback_exception(self);
return err;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git
More information about the Pkg-gnupg-commit
mailing list