void-packages/srcpkgs/screenplain/patches/python3-stdout-buffer.patch
2020-05-14 08:46:16 -05:00

35 lines
1.3 KiB
Diff

https://github.com/vilcans/screenplain/commit/e946ac7cdb4e61458502da629d79d78cac22d060.patch
From e946ac7cdb4e61458502da629d79d78cac22d060 Mon Sep 17 00:00:00 2001
From: Jakub Stasiak <jakub@stasiak.at>
Date: Sat, 8 Feb 2020 13:52:06 +0100
Subject: [PATCH] Fix "TypeError: write() argument must be str, not bytes" on
Python 3
This used to happen when writing to stdout. On Python 3 stdout is an
instance of TextIOWrapper which is a text-based interface. It wraps a
bytes-based writer though which is accessible through the buffer
attribute, so let's use that to either write to it directly or to get an
encoding writer.
Fixes https://github.com/vilcans/screenplain/issues/53.
---
screenplain/main.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/screenplain/main.py b/screenplain/main.py
index 770427c..313498f 100644
--- a/screenplain/main.py
+++ b/screenplain/main.py
@@ -109,9 +109,9 @@ def main(args):
output = open(output_file, 'wb')
else:
if output_encoding:
- output = codecs.getwriter(output_encoding)(sys.stdout)
+ output = codecs.getwriter(output_encoding)(sys.stdout.buffer)
else:
- output = sys.stdout
+ output = sys.stdout.buffer
try:
if format == 'text':