Skip to content

Commit

Permalink
Merge pull request #74: Bug fix for converter module on Python 3 on M…
Browse files Browse the repository at this point in the history
…acOS
  • Loading branch information
xolox committed Feb 14, 2020
2 parents 4e815b1 + 8a17fa0 commit 0229245
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion coloredlogs/converter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def capture(command, encoding='UTF-8'):
try:
command_line = ['script', '-q', temporary_file] + list(command)
subprocess.Popen(command_line, stdout=dev_null, stderr=dev_null).wait()
with codecs.open(temporary_file, 'r', encoding) as handle:
with codecs.open(temporary_file, 'rb') as handle:
output = handle.read()
finally:
os.unlink(temporary_file)
Expand All @@ -112,6 +112,7 @@ def capture(command, encoding='UTF-8'):
# [1] https://en.wikipedia.org/wiki/End-of-file
if output.startswith(b'^D'):
output = output[2:]
output = output.decode(encoding)
# Clean up backspace and carriage return characters and the 'erase line'
# ANSI escape sequence and return the output as a Unicode string.
return u'\n'.join(clean_terminal_output(output))
Expand Down

0 comments on commit 0229245

Please sign in to comment.