[Pkg-gnupg-commit] [gpgme] 91/412: python: Cache generated wrapper functions.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Thu Sep 22 21:26:23 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 ed0ce84fbd2904bf59ac66ae7422716db3624efa
Author: Justus Winter <justus at gnupg.org>
Date:   Thu May 12 14:57:42 2016 +0200

    python: Cache generated wrapper functions.
    
    * lang/python/util.py (GpgmeWrap.__getattr__): Cache generated wrapper
    functions.
    
    Signed-off-by: Justus Winter <justus at gnupg.org>
---
 lang/python/pyme/util.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lang/python/pyme/util.py b/lang/python/pyme/util.py
index 19bbb7f..a856099 100644
--- a/lang/python/pyme/util.py
+++ b/lang/python/pyme/util.py
@@ -69,11 +69,11 @@ class GpgmeWrapper(object):
         returning gpgme_error_t."""
         raise NotImplementedError()
 
-    def __getattr__(self, name):
+    def __getattr__(self, key):
         """On-the-fly function generation."""
-        if name[0] == '_' or self._getnameprepend() == None:
+        if key[0] == '_' or self._getnameprepend() == None:
             return None
-        name = self._getnameprepend() + name
+        name = self._getnameprepend() + key
         if self._errorcheck(name):
             def _funcwrap(*args, **kwargs):
                 args = [self.wrapped] + list(args)
@@ -85,5 +85,8 @@ class GpgmeWrapper(object):
                 return getattr(pygpgme, name)(*args, **kwargs)
 
         _funcwrap.__doc__ = getattr(getattr(pygpgme, name), "__doc__")
+
+        # Cache the wrapper function.
+        setattr(self, key, _funcwrap)
         return _funcwrap
 

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