aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/pyme/core.py
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-05-12 16:00:16 +0000
committerJustus Winter <[email protected]>2016-05-12 16:01:24 +0000
commitc5d118b2a76e9528df780d11da9566ff7c22e4f5 (patch)
treed4d27b83319d007cb8bcdc3b6cffd7628cebe995 /lang/python/pyme/core.py
parentpython: Fix writing to data buffers. (diff)
downloadgpgme-c5d118b2a76e9528df780d11da9566ff7c22e4f5.tar.gz
gpgme-c5d118b2a76e9528df780d11da9566ff7c22e4f5.zip
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 <[email protected]>
Diffstat (limited to 'lang/python/pyme/core.py')
-rw-r--r--lang/python/pyme/core.py5
1 files changed, 4 insertions, 1 deletions
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.