Fix Python 2 Unicode Problem
When piping to stdout the special handling for Pthon 3 will cause problems in Python 2 and produce an Unicode encoding error. This commit separates the output handling of both Python versions. Signed-off-by: Lars Kiesow <lkiesow@uos.de>
This commit is contained in:
parent
5caebc220c
commit
9b6e3cb45e
1 changed files with 4 additions and 1 deletions
|
@ -15,7 +15,10 @@ def print_enc(s):
|
|||
'''Print function compatible with both python2 and python3 accepting strings
|
||||
and byte arrays.
|
||||
'''
|
||||
print(s.decode('utf-8') if type(s) == type(b'') else s)
|
||||
if sys.version_info[0] >= 3:
|
||||
print(s.decode('utf-8') if type(s) == type(b'') else s)
|
||||
else:
|
||||
print(s)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue