21 lines
896 B
Diff
21 lines
896 B
Diff
Author: Carl Suster <carl@contraflo.ws>
|
|
Description: Avoid writing bytes to stdout
|
|
In Python 3, bytes should be written to the underlying buffer object
|
|
rather than directly to stdout. This was causing legitimate test
|
|
failures.
|
|
|
|
diff -Naurp terminaltables.orig/terminaltables/terminal_io.py terminaltables/terminaltables/terminal_io.py
|
|
--- terminaltables.orig/terminaltables/terminal_io.py
|
|
+++ terminaltables/terminaltables/terminal_io.py
|
|
@@ -94,5 +94,10 @@ def set_terminal_title(title, kernel32=N
|
|
return kernel32.SetConsoleTitleW(title) != 0
|
|
|
|
# Linux/OSX.
|
|
- sys.stdout.write(b'\033]0;' + title_bytes + b'\007')
|
|
+ set_title = b'\033]0;' + title_bytes + b'\007'
|
|
+ if hasattr(sys.stdout, 'buffer'):
|
|
+ sys.stdout.buffer.write(set_title)
|
|
+ else:
|
|
+ text = set_title.decode(sys.stdout.encoding, 'strict')
|
|
+ sys.stdout.write(text)
|
|
return True
|