[git] GPGME - branch, master, updated. gpgme-1.9.0-87-g3cf9aed

by Tobias Mueller cvs at cvs.gnupg.org
Mon Dec 4 08:16:30 CET 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, master has been updated
       via  3cf9aedc92b6c65d2cb34037e52b9a299637d03b (commit)
      from  2205ee2cd92233506ab5a54111160cd8d62ae411 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 3cf9aedc92b6c65d2cb34037e52b9a299637d03b
Author: Tobias Mueller <muelli at cryptobitch.de>
Date:   Tue Aug 22 17:48:25 2017 +0200

    python: Default whence argument for Data() to SEEK_SET.
    
    * lang/python/gpgme.i: copied signature from gpgme.h and defaulted the
    value to SEEK_SET.
    * lang/python/tests/t-data.py: Added a test for no second argument
    --
    
    Having to import the os package when wanting to read a Data object is a
    slight annoyance. With SWIG, we can define default parameters. This
    change defaults the whence argument to SEEK_SET which is how StringIO
    and BytesIO behave.
    
    Signed-off-by: Tobias Mueller <muelli at cryptobitch.de>

diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index 610b3d9..492326b 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -557,6 +557,11 @@ gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx,
                       const char *pattern="",
                       int secret_only=0);
 
+/* The whence argument is surprising in Python-land,
+   because BytesIO or StringIO objects do not require it.
+   It defaults to SEEK_SET. Let's do that for Data objects, too */
+off_t gpgme_data_seek (gpgme_data_t dh, off_t offset, int whence=SEEK_SET);
+
 /* Include the unmodified <gpgme.h> for cc, and the cleaned-up local
    version for SWIG.  We do, however, want to hide certain fields on
    some structs, which we provide prior to including the version for
diff --git a/lang/python/tests/t-data.py b/lang/python/tests/t-data.py
index 3301319..5cf074c 100755
--- a/lang/python/tests/t-data.py
+++ b/lang/python/tests/t-data.py
@@ -51,6 +51,12 @@ data.write(b'Hello world!')
 data.seek(0, os.SEEK_SET)
 assert data.read() == b'Hello world!'
 
+data = gpg.Data()
+data.write(b'Hello world!')
+# We expect the second argument to default to SEEK_SET
+data.seek(0)
+assert data.read() == b'Hello world!'
+
 binjunk = bytes(range(256))
 data = gpg.Data()
 data.write(binjunk)

-----------------------------------------------------------------------

Summary of changes:
 lang/python/gpgme.i         | 5 +++++
 lang/python/tests/t-data.py | 6 ++++++
 2 files changed, 11 insertions(+)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org




More information about the Gnupg-commits mailing list