From c5d118b2a76e9528df780d11da9566ff7c22e4f5 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 12 May 2016 18:00:16 +0200 Subject: python: Raise exceptions on write errors. * lang/python/pyme/core.py (Data.write): Handle errors. * lang/python/pyme/errors.py (GPGMEError.fromSyserror): New function. Signed-off-by: Justus Winter --- lang/python/pyme/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lang/python/pyme/core.py') diff --git a/lang/python/pyme/core.py b/lang/python/pyme/core.py index dafbd9b3..1d6e3847 100644 --- a/lang/python/pyme/core.py +++ b/lang/python/pyme/core.py @@ -394,7 +394,10 @@ class Data(GpgmeWrapper): """Write buffer given as string or bytes. If a string is given, it is implicitly encoded using UTF-8.""" - return pygpgme.gpgme_data_write(self.wrapped, buffer) + written = pygpgme.gpgme_data_write(self.wrapped, buffer) + if written < 0: + raise GPGMEError.fromSyserror() + return written def read(self, size = -1): """Read at most size bytes, returned as bytes. -- cgit v1.2.3