aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/examples/simple.py
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-05-12 09:21:58 +0000
committerJustus Winter <[email protected]>2016-05-12 09:49:17 +0000
commitd60deb8a127fb35c01acc729f33b014840af0e7b (patch)
treed5188d0cc07273b80e6728b1e95fc757c7630e5d /lang/python/examples/simple.py
parentpython: Fix simple example. (diff)
downloadgpgme-d60deb8a127fb35c01acc729f33b014840af0e7b.tar.gz
gpgme-d60deb8a127fb35c01acc729f33b014840af0e7b.zip
python: Fix type translation.
* lang/python/gpgme.i: Adjust to Python3's string type being 'Unicode', not 'bytes'. Fix type checking. * lang/python/core.py (Data.write): Add docstring mentioning the expected type of parameter 'buffer'. (Data.read): Adjust read loop. Also, use a saner chunk size, and join all chunks at the end instead of adding them. * lang/python/examples/simple.py: Adjust example. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'lang/python/examples/simple.py')
-rwxr-xr-xlang/python/examples/simple.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/lang/python/examples/simple.py b/lang/python/examples/simple.py
index 739291ed..4ff6d285 100755
--- a/lang/python/examples/simple.py
+++ b/lang/python/examples/simple.py
@@ -25,7 +25,7 @@ core.check_version(None)
# Set up our input and output buffers.
-plain = core.Data(b'This is my message.')
+plain = core.Data('This is my message.')
cipher = core.Data()
# Initialize our context.
@@ -38,7 +38,7 @@ c.set_armor(1)
sys.stdout.write("Enter name of your recipient: ")
sys.stdout.flush()
name = sys.stdin.readline().strip()
-c.op_keylist_start(name.encode(), 0)
+c.op_keylist_start(name, 0)
r = c.op_keylist_next()
if r == None:
@@ -48,6 +48,6 @@ else:
try:
c.op_encrypt([r], 1, plain, cipher)
cipher.seek(0,0)
- print(cipher.read())
+ sys.stdout.buffer.write(cipher.read())
except errors.GPGMEError as ex:
print(ex.getstring())