[Pkg-gnupg-commit] [gpgme] 07/132: python: Check "buffer" when writing to sys.stdout for python2 compat.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Apr 26 01:00:46 UTC 2017


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch experimental
in repository gpgme.

commit ae21d2705fc46725e1f9af1651b68d16155d1501
Author: Tobias Mueller <muelli at cryptobitch.de>
Date:   Wed Nov 30 23:08:47 2016 +0100

    python: Check "buffer" when writing to sys.stdout for python2 compat.
    
    * lang/python/tests/support.py (print_data): Add check for buffer.
    --
    
    When running with something like make -C lang/python check verbose=2 the
    test would fail under python2, because the file objects do not have a
    buffer property.
    
    Signed-off-by: Tobias Mueller <muelli at cryptobitch.de>
---
 lang/python/tests/support.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lang/python/tests/support.py b/lang/python/tests/support.py
index f991c6d..0b04bb6 100644
--- a/lang/python/tests/support.py
+++ b/lang/python/tests/support.py
@@ -48,7 +48,11 @@ def print_data(data):
         except:
             # Hope for the best.
             pass
-        sys.stdout.buffer.write(data)
+
+        if hasattr(sys.stdout, "buffer"):
+            sys.stdout.buffer.write(data)
+        else:
+            sys.stdout.write(data)
 
 def mark_key_trusted(ctx, key):
     class Editor(object):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gpgme.git



More information about the Pkg-gnupg-commit mailing list