Possible bug in GPGME Python

Ingo Klöcker kloecker at kde.org
Mon Jun 17 22:00:47 CEST 2024


On Samstag, 4. Mai 2024 15:55:40 CEST meep via Gnupg-devel wrote:
> I would like to report what I believe to be an oversight in the Python
> wrapper of GPGME.

It's not an oversight. It's the result of the fact that the Python bindings 
effectively haven't seen any real development in the last 5 years. They do not 
support any of the new features that were added to GpgME in the last few 
years.

> In the interact(...) function of the Context class on line 1089 in
> core.py it is checked whether a key is actually passed in to the
> function:
> 
> if key is None:
>     raise ValueError("First argument cannot be None")

Which was correct at the time this code was written.

> Which is fine when editing a key, but when interacting with a smart
> card (setting the flag INTERACT_CARD) - for example to generate a key
> on it - there is not necessarily a key to be edited.
> 
> In interact_start(...) on line 131 of edit.c the presence of the key is
> only checked if card_edit isn't set:
> 
> if ((card_edit == 0 && !key) || !fnc || !out)
>   return gpg_error (GPG_ERR_INV_VALUE);

This change has been made about 18 months ago.

> Thus I believe that the intended behavior in Python would be to mirror
> the C code and only check whether the key is None if INTERACT_CARD is
> not set.

This is correct. Patches are welcome. See the file doc/HACKING for details.

Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.gnupg.org/pipermail/gnupg-devel/attachments/20240617/97954a61/attachment.sig>


More information about the Gnupg-devel mailing list