[PATCH] python: default op_keylist_start parameters.

Justus Winter justus at g10code.com
Mon Dec 5 12:55:50 CET 2016

Tobias Mueller <muelli at cryptobitch.de> writes:

> * lang/python/gpgme.i: Added gpgme_op_keylist_start with defaults
> * lang/python/tests/t-keylist.py: Added tests for default parameters


> +/* With SWIG, you can define default arguments for parameters.
> + * While it's legal in C++ it is not in C, so we cannot change the
> + * already existing gpgme.h. We need, however, to declare the function
> + * *before* SWIG loads it from gpgme.h. Hence, we define it here.     */
> +gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx,
> +                      const char *pattern="",
> +                      int secret_only=0);

Interesting, I didn't know that.  Is SWIG using C++ under the hood, or
are they parsing this and changing the prologue of the generated wrapper

I'm not sure whether we want to do this or not.  Currently, we provide a
very faithful "C-like API", and a idiomatic Python API on top.  And
indeed, in the idiomatic key listing API we provide exactly these

    def keylist(self, pattern=None, secret=False):
        """List keys

        Keyword arguments:
        pattern	-- return keys matching pattern (default: all keys)
        secret	-- return only secret keys

Your patch deviates from that pattern.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: </pipermail/attachments/20161205/90a30351/attachment.sig>

More information about the Gnupg-devel mailing list