python: Reset passphrase callback correctly.

* lang/python/src/core.py (Context(GpgmeWrapper)): Reset passphrase
callback correctly, for encrypt, decrypt, create_key, and
create_subkey methods.

--

Signed-off-by: Jasper Spaans <jasper@startmail.com>
This commit is contained in:
Jasper Spaans 2022-08-05 11:02:44 +09:00 committed by NIIBE Yutaka
parent c3b183831d
commit b2f224a471

View File

@ -332,8 +332,7 @@ class Context(GpgmeWrapper):
finally:
if passphrase is not None:
self.pinentry_mode = old_pinentry_mode
if old_passphrase_cb:
self.set_passphrase_cb(*old_passphrase_cb[1:])
gpgme.gpg_set_passphrase_cb(self, old_passphrase_cb)
result = self.op_encrypt_result()
assert not result.invalid_recipients
@ -426,8 +425,7 @@ class Context(GpgmeWrapper):
finally:
if passphrase is not None:
self.pinentry_mode = old_pinentry_mode
if old_passphrase_cb:
self.set_passphrase_cb(*old_passphrase_cb[1:])
gpgme.gpg_set_passphrase_cb(self, old_passphrase_cb)
result = self.op_decrypt_result()
@ -851,8 +849,7 @@ class Context(GpgmeWrapper):
finally:
if util.is_a_string(passphrase):
self.pinentry_mode = old_pinentry_mode
if old_passphrase_cb:
self.set_passphrase_cb(*old_passphrase_cb[1:])
gpgme.gpg_set_passphrase_cb(self, old_passphrase_cb)
return self.op_genkey_result()
@ -934,8 +931,7 @@ class Context(GpgmeWrapper):
finally:
if util.is_a_string(passphrase):
self.pinentry_mode = old_pinentry_mode
if old_passphrase_cb:
self.set_passphrase_cb(*old_passphrase_cb[1:])
gpgme.gpg_set_passphrase_cb(self, old_passphrase_cb)
return self.op_genkey_result()