[Pkg-gnupg-commit] [gpgme] 163/412: python: Fix type.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 22 21:26:39 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 990492ea4f7dafbb75de15ea91c30cbf090034b5
Author: Justus Winter <justus at g10code.com>
Date:   Wed Jun 8 17:04:02 2016 +0200

    python: Fix type.
    
    * lang/python/gpgme.i: Use correct Python type for size.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 lang/python/gpgme.i | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index f466a87..98f30d5 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -183,18 +183,28 @@
 
 /* For gpgme_data_write, but should be universal.  */
 %typemap(in) (const void *buffer, size_t size) {
+  Py_ssize_t ssize;
+
   if ($input == Py_None)
     $1 = NULL, $2 = 0;
   else if (PyUnicode_Check($input))
-    $1 = PyUnicode_AsUTF8AndSize($input, (size_t *) &$2);
+    $1 = PyUnicode_AsUTF8AndSize($input, &ssize);
   else if (PyBytes_Check($input))
-    PyBytes_AsStringAndSize($input, (char **) &$1, (size_t *) &$2);
+    PyBytes_AsStringAndSize($input, (char **) &$1, &ssize);
   else {
     PyErr_Format(PyExc_TypeError,
                  "arg %d: expected str, bytes, or None, got %s",
 		 $argnum, $input->ob_type->tp_name);
     return NULL;
   }
+
+  if (! $1)
+    $2 = 0;
+  else
+    {
+      assert (ssize >= 0);
+      $2 = (size_t) ssize;
+    }
 }
 %typemap(freearg) (const void *buffer, size_t size) "";
 

-- 
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