From d60deb8a127fb35c01acc729f33b014840af0e7b Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 12 May 2016 11:21:58 +0200 Subject: 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 --- lang/python/examples/simple.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lang/python/examples/simple.py') 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()) -- cgit v1.2.3