diff options
Diffstat (limited to 'lang/python/pyme')
| -rw-r--r-- | lang/python/pyme/core.py | 10 | ||||
| -rw-r--r-- | lang/python/pyme/util.py | 16 | 
2 files changed, 18 insertions, 8 deletions
| diff --git a/lang/python/pyme/core.py b/lang/python/pyme/core.py index 2a0ca072..8a4c197e 100644 --- a/lang/python/pyme/core.py +++ b/lang/python/pyme/core.py @@ -54,14 +54,14 @@ class Context(GpgmeWrapper):      def __init__(self, wrapped=None):          if wrapped: -            self.wrapped = wrapped              self.own = False          else:              tmp = pygpgme.new_gpgme_ctx_t_p()              errorcheck(pygpgme.gpgme_new(tmp)) -            self.wrapped = pygpgme.gpgme_ctx_t_p_value(tmp) +            wrapped = pygpgme.gpgme_ctx_t_p_value(tmp)              pygpgme.delete_gpgme_ctx_t_p(tmp)              self.own = True +        super().__init__(wrapped)          self.last_passcb = None          self.last_progresscb = None @@ -167,9 +167,9 @@ class Context(GpgmeWrapper):          else:              self.last_passcb = pygpgme.new_PyObject_p_p()              if hook == None: -                hookdata = func +                hookdata = (self, func)              else: -                hookdata = (func, hook) +                hookdata = (self, func, hook)          pygpgme.pygpgme_set_passphrase_cb(self.wrapped, hookdata, self.last_passcb)      def set_progress_cb(self, func, hook=None): @@ -282,7 +282,7 @@ class Data(GpgmeWrapper):          that file.          Any other use will result in undefined or erroneous behavior.""" -        self.wrapped = None +        super().__init__(None)          self.last_readcb = None          if cbs != None: diff --git a/lang/python/pyme/util.py b/lang/python/pyme/util.py index 3c34c79e..b54cd4dc 100644 --- a/lang/python/pyme/util.py +++ b/lang/python/pyme/util.py @@ -32,6 +32,11 @@ def process_constants(starttext, dict):  class GpgmeWrapper(object):      """Base class all Pyme wrappers for GPGME functionality.  Not to be      instantiated directly.""" + +    def __init__(self, wrapped): +        self._callback_excinfo = None +        self.wrapped = wrapped +      def __repr__(self):          return '<instance of %s.%s with GPG object at %s>' % \                 (__name__, self.__class__.__name__, @@ -78,11 +83,16 @@ class GpgmeWrapper(object):          if self._errorcheck(name):              def _funcwrap(slf, *args, **kwargs): -                return errorcheck(func(slf.wrapped, *args, **kwargs), -                                  "Invocation of " + name) +                result = func(slf.wrapped, *args, **kwargs) +                if slf._callback_excinfo: +                    pygpgme.pygpgme_raise_callback_exception(slf) +                return errorcheck(result, "Invocation of " + name)          else:              def _funcwrap(slf, *args, **kwargs): -                return func(slf.wrapped, *args, **kwargs) +                result = func(slf.wrapped, *args, **kwargs) +                if slf._callback_excinfo: +                    pygpgme.pygpgme_raise_callback_exception(slf) +                return result          _funcwrap.__doc__ = getattr(func, "__doc__") | 
