Skip to content

Commit

Permalink
io: fix for unicode errors when logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jbohren committed May 4, 2016
1 parent 38fd58a commit 8e28328
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion catkin_tools/execution/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@

MAX_LOGFILE_HISTORY = 10

if type(u'') == str:
def _encode(string):
"""Encode a Python 3 str into bytes.
:type data: str
"""
return string.encode('utf-8')
else:
def _encode(string):
"""Encode a Python 2 str into bytes.
:type data: str
"""
return string.decode('utf-8').encode('utf-8')


class IOBufferContainer(object):

Expand Down Expand Up @@ -109,7 +122,7 @@ def _encode(self, data):
"""Encode a Python str into bytes.
:type data: str
"""
return data.encode('utf-8')
return _encode(data)

def _decode(self, data):
"""Decode bytes into Python str.
Expand Down

0 comments on commit 8e28328

Please sign in to comment.