[Pkg-gnupg-commit] [gpgme] 250/412: python: Improve error handling.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 22 21:26:57 UTC 2016


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

dkg pushed a commit to branch master
in repository gpgme.

commit 5a7c7a86f7e8eaf10e37138617a2d838f9d4466f
Author: Justus Winter <justus at g10code.com>
Date:   Thu Jul 28 17:44:18 2016 +0200

    python: Improve error handling.
    
    * lang/python/pyme/core.py (Context.protocol): Check that the engine
    is usable before setting the protocol.
    (Context._errorcheck): Add missing functions.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 lang/python/pyme/core.py | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/lang/python/pyme/core.py b/lang/python/pyme/core.py
index 50c6c0f..e12dc7b 100644
--- a/lang/python/pyme/core.py
+++ b/lang/python/pyme/core.py
@@ -546,6 +546,7 @@ class Context(GpgmeWrapper):
         return self.get_protocol()
     @protocol.setter
     def protocol(self, value):
+        errorcheck(gpgme.gpgme_engine_check_version(value))
         self.set_protocol(value)
 
     _ctype = 'gpgme_ctx_t'
@@ -553,14 +554,23 @@ class Context(GpgmeWrapper):
 
     def _errorcheck(self, name):
         """This function should list all functions returning gpgme_error_t"""
-        if (name.startswith('gpgme_op_') and \
-            not name.endswith('_result')) or \
-            name == 'gpgme_signers_add' or \
-            name == 'gpgme_set_locale' or \
-            name == 'gpgme_set_keylist_mode' or \
-            name == 'gpgme_set_protocol':
-            return 1
-        return 0
+        return ((name.startswith('gpgme_op_')
+                 and not name.endswith('_result'))
+                or name in {
+                    'gpgme_set_ctx_flag',
+                    'gpgme_set_protocol',
+                    'gpgme_set_sub_protocol',
+                    'gpgme_set_keylist_mode',
+                    'gpgme_set_pinentry_mode',
+                    'gpgme_set_locale',
+                    'gpgme_set_engine_info',
+                    'gpgme_signers_add',
+                    'gpgme_get_sig_key',
+                    'gpgme_sig_notation_add',
+                    'gpgme_cancel',
+                    'gpgme_cancel_async',
+                    'gpgme_cancel_get_key',
+                })
 
     _boolean_properties = {'armor', 'textmode', 'offline'}
 

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