python: Improve build system integration, fix warnings.
authorJustus Winter <justus@g10code.com>
Wed, 1 Jun 2016 12:16:27 +0000 (14:16 +0200)
committerJustus Winter <justus@g10code.com>
Wed, 1 Jun 2016 12:18:45 +0000 (14:18 +0200)
* lang/python/Makefile.am: Pass CFLAGS to python build system.
* lang/python/helpers.c (pyPassphraseCb): Use correct type for length.
(pygpgme_data_new_from_cbs): Drop unused variable.

Signed-off-by: Justus Winter <justus@g10code.com>
lang/python/Makefile.am
lang/python/helpers.c

index 8034922..18f77bb 100644 (file)
@@ -40,7 +40,7 @@ gpgme_wrap.c pyme/pygpgme.py: gpgme.i errors.i gpgme.h copystamp
          $<
 
 all-local: gpgme_wrap.c pyme/pygpgme.py copystamp
-       $(PYTHON) $(srcdir)/setup.py build --verbose
+       CFLAGS="$(CFLAGS)" $(PYTHON) $(srcdir)/setup.py build --verbose
 
 clean-local:
        rm -rf -- build gpgme.h errors.i gpgme_wrap.c pyme/pygpgme.py \
index 4792c87..4bbc298 100644 (file)
@@ -207,7 +207,12 @@ static gpgme_error_t pyPassphraseCb(void *hook,
       if (PyBytes_Check(retval))
         buf = PyBytes_AsString(retval), len = PyBytes_Size(retval);
       else if (PyUnicode_Check(retval))
-        buf = PyUnicode_AsUTF8AndSize(retval, &len);
+        {
+          Py_ssize_t ssize;
+          buf = PyUnicode_AsUTF8AndSize(retval, &ssize);
+          assert (! buf || ssize >= 0);
+          len = (size_t) ssize;
+        }
       else
         {
           PyErr_Format(PyExc_TypeError,
@@ -634,7 +639,6 @@ gpgme_error_t pygpgme_data_new_from_cbs(gpgme_data_t *r_data,
     pyDataSeekCb,
     pyDataReleaseCb,
   };
-  PyObject *dataarg = NULL;
 
   assert (PyTuple_Check(pycbs));
   assert (PyTuple_Size(pycbs) == 5 || PyTuple_Size(pycbs) == 6);