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@cryptobitch.de>
This commit is contained in:
Tobias Mueller 2016-11-30 23:08:47 +01:00 committed by Justus Winter
parent 154389f2a5
commit ae21d2705f

View File

@ -48,7 +48,11 @@ def print_data(data):
except:
# Hope for the best.
pass
if hasattr(sys.stdout, "buffer"):
sys.stdout.buffer.write(data)
else:
sys.stdout.write(data)
def mark_key_trusted(ctx, key):
class Editor(object):