[Pkg-gnupg-commit] [gpgme] 03/05: pull in more upstream python fixes

Daniel Kahn Gillmor dkg at fifthhorseman.net
Fri Oct 14 20:31:13 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch experimental
in repository gpgme.

commit 7501c2a52460fbf45b0d331d073741bdcda1b3dd
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date:   Fri Oct 14 16:04:20 2016 -0400

    pull in more upstream python fixes
---
 .../0009-python-Correctly-translate-off_t.patch    | 64 ++++++++++++++++++
 ...0010-python-Correctly-translate-to-size_t.patch | 52 +++++++++++++++
 ...thon-Get-rid-of-the-last-C-style-comments.patch | 77 ++++++++++++++++++++++
 debian/patches/series                              |  3 +
 4 files changed, 196 insertions(+)

diff --git a/debian/patches/0009-python-Correctly-translate-off_t.patch b/debian/patches/0009-python-Correctly-translate-off_t.patch
new file mode 100644
index 0000000..2680ef0
--- /dev/null
+++ b/debian/patches/0009-python-Correctly-translate-off_t.patch
@@ -0,0 +1,64 @@
+From: Justus Winter <justus at g10code.com>
+Date: Mon, 26 Sep 2016 13:04:35 +0200
+Subject: python: Correctly translate off_t.
+
+* lang/python/gpgme.i: Improve int/long translations, correctly handle
+off_t with large file support.
+
+Signed-off-by: Justus Winter <justus at g10code.com>
+---
+ lang/python/gpgme.i | 39 ++++++++++++++++++++++++++++++++++-----
+ 1 file changed, 34 insertions(+), 5 deletions(-)
+
+diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
+index a4672e1..934ebea 100644
+--- a/lang/python/gpgme.i
++++ b/lang/python/gpgme.i
+@@ -291,13 +291,42 @@
+ 
+ /* SWIG has problems interpreting ssize_t, off_t or gpgme_error_t in
+    gpgme.h.  */
+-/* XXX: This is wrong at least for off_t if compiled with LFS.  */
+-%typemap(out) ssize_t, off_t, gpgme_error_t, gpgme_err_code_t, gpgme_err_source_t, gpg_error_t {
++%typemap(out) ssize_t, gpgme_error_t, gpgme_err_code_t, gpgme_err_source_t, gpg_error_t {
+   $result = PyLong_FromLong($1);
+ }
+-/* XXX: This is wrong at least for off_t if compiled with LFS.  */
+-%typemap(in) ssize_t, off_t, gpgme_error_t, gpgme_err_code_t, gpgme_err_source_t, gpg_error_t {
+-  $1 = PyLong_AsLong($input);
++
++%typemap(in) ssize_t, gpgme_error_t, gpgme_err_code_t, gpgme_err_source_t, gpg_error_t {
++  if (PyLong_Check($input))
++    $1 = PyLong_AsLong($input);
++#if PY_MAJOR_VERSION < 3
++  else if (PyInt_Check($input))
++    $1 = PyInt_AsLong($input);
++#endif
++  else
++    PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
++}
++
++%typemap(out) off_t {
++#if _FILE_OFFSET_BITS == 64
++  $result = PyLong_FromLongLong($1);
++#else
++  $result = PyLong_FromLong($1);
++#endif
++}
++
++%typemap(in) off_t {
++  if (PyLong_Check($input))
++#if _FILE_OFFSET_BITS == 64
++    $1 = PyLong_AsLongLong($input);
++#else
++    $1 = PyLong_AsLong($input);
++#endif
++#if PY_MAJOR_VERSION < 3
++  else if (PyInt_Check($input))
++    $1 = PyInt_AsLong($input);
++#endif
++  else
++    PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
+ }
+ 
+ // Those are for gpgme_data_read() and gpgme_strerror_r()
diff --git a/debian/patches/0010-python-Correctly-translate-to-size_t.patch b/debian/patches/0010-python-Correctly-translate-to-size_t.patch
new file mode 100644
index 0000000..99f3c45
--- /dev/null
+++ b/debian/patches/0010-python-Correctly-translate-to-size_t.patch
@@ -0,0 +1,52 @@
+From: Justus Winter <justus at g10code.com>
+Date: Mon, 26 Sep 2016 13:16:59 +0200
+Subject: python: Correctly translate to size_t.
+
+* lang/python/gpgme.i: Correctly translate Python number to size_t.
+
+Signed-off-by: Justus Winter <justus at g10code.com>
+---
+ lang/python/gpgme.i | 29 ++++++++++++++++++++++-------
+ 1 file changed, 22 insertions(+), 7 deletions(-)
+
+diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
+index 934ebea..04257fd 100644
+--- a/lang/python/gpgme.i
++++ b/lang/python/gpgme.i
+@@ -329,14 +329,29 @@
+     PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
+ }
+ 
+-// Those are for gpgme_data_read() and gpgme_strerror_r()
++/* Those are for gpgme_data_read() and gpgme_strerror_r().  */
+ %typemap(in) (void *buffer, size_t size), (char *buf, size_t buflen) {
+-   $2 = PyLong_AsLong($input);
+-   if ($2 < 0) {
+-     PyErr_SetString(PyExc_ValueError, "Positive integer expected");
+-     return NULL;
+-   }
+-   $1 = ($1_ltype) malloc($2+1);
++  {
++    long tmp$argnum;
++    if (PyLong_Check($input))
++      tmp$argnum = PyLong_AsLong($input);
++#if PY_MAJOR_VERSION < 3
++    else if (PyInt_Check($input))
++      tmp$argnum = PyInt_AsLong($input);
++#endif
++    else
++      {
++        PyErr_SetString(PyExc_TypeError, "Numeric argument expected");
++        return NULL;
++      }
++
++    if (tmp$argnum < 0) {
++      PyErr_SetString(PyExc_ValueError, "Positive integer expected");
++      return NULL;
++    }
++    $2 = (size_t) tmp$argnum;
++    $1 = ($1_ltype) malloc($2+1);
++  }
+ }
+ %typemap(argout) (void *buffer, size_t size), (char *buf, size_t buflen) {
+   Py_XDECREF($result);   /* Blow away any previous result */
diff --git a/debian/patches/0011-python-Get-rid-of-the-last-C-style-comments.patch b/debian/patches/0011-python-Get-rid-of-the-last-C-style-comments.patch
new file mode 100644
index 0000000..3843818
--- /dev/null
+++ b/debian/patches/0011-python-Get-rid-of-the-last-C-style-comments.patch
@@ -0,0 +1,77 @@
+From: Justus Winter <justus at g10code.com>
+Date: Mon, 26 Sep 2016 16:45:21 +0200
+Subject: python: Get rid of the last C++-style comments.
+
+--
+Signed-off-by: Justus Winter <justus at g10code.com>
+---
+ lang/python/gpgme.i | 14 +++++++-------
+ 1 file changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
+index 04257fd..eaeb4f8 100644
+--- a/lang/python/gpgme.i
++++ b/lang/python/gpgme.i
+@@ -110,7 +110,7 @@
+     Py_XDECREF(pyVector$argnum[i]);
+ }
+ 
+-// Release returned buffers as necessary.
++/* Release returned buffers as necessary.  */
+ %typemap(newfree) char * "free($1);";
+ %newobject gpgme_data_release_and_get_mem;
+ 
+@@ -133,7 +133,7 @@
+       /* input = $input, 1 = $1, 1_descriptor = $1_descriptor */
+       /* &1_descriptor = $&1_descriptor *1_descriptor = $*1_descriptor */
+ 
+-      // Following code is from swig's python.swg
++      /* 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);
+ 	return NULL;
+@@ -147,7 +147,7 @@
+   if ($1) free($1);
+ }
+ 
+-// Special handling for references to our objects.
++/* Special handling for references to our objects.  */
+ %typemap(in) gpgme_data_t DATAIN (gpgme_data_t wrapper = NULL,
+                                   PyObject *bytesio = NULL,
+                                   Py_buffer view, int have_view = 0) {
+@@ -167,7 +167,7 @@
+ 
+     /* input = $input, 1 = $1, 1_descriptor = $1_descriptor */
+ 
+-    // Following code is from swig's python.swg
++    /* Following code is from swig's python.swg.  */
+ 
+     if ((SWIG_ConvertPtr(pypointer,(void **) &$1, $1_descriptor,
+          SWIG_POINTER_EXCEPTION | $disown )) == -1) {
+@@ -401,7 +401,7 @@
+   Py_XDECREF(encodedInput$argnum);
+ }
+ 
+-// Make types containing 'next' field to be lists
++/* Make types containing 'next' field to be lists.  */
+ %ignore next;
+ %typemap(out) gpgme_sig_notation_t, gpgme_subkey_t,
+    gpgme_key_sig_t, gpgme_user_id_t, gpgme_invalid_key_t,
+@@ -631,7 +631,7 @@ struct _gpgme_sig_notation
+ 
+ %include "errors.i"
+ 
+-// Generating and handling pointers-to-pointers.
++/* Generating and handling pointers-to-pointers.  */
+ 
+ %pointer_functions(gpgme_ctx_t, gpgme_ctx_t_p);
+ %pointer_functions(gpgme_data_t, gpgme_data_t_p);
+@@ -640,7 +640,7 @@ struct _gpgme_sig_notation
+ %pointer_functions(gpgme_trust_item_t, gpgme_trust_item_t_p);
+ %pointer_functions(gpgme_engine_info_t, gpgme_engine_info_t_p);
+ 
+-// Helper functions.
++/* Helper functions.  */
+ 
+ %{
+ #include <stdio.h>
diff --git a/debian/patches/series b/debian/patches/series
index 6c8916a..9517b28 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -6,3 +6,6 @@
 0006-install-cmake-files-without-executable-bit-set.patch
 0007-make-documentation-reproducible-by-omitting-HTML_TIM.patch
 0008-python-Include-config.h.patch
+0009-python-Correctly-translate-off_t.patch
+0010-python-Correctly-translate-to-size_t.patch
+0011-python-Get-rid-of-the-last-C-style-comments.patch

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