From 2554112045b850764a728124b7cba966eca6aacc Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 12 Apr 2021 10:17:12 -0400 Subject: [PATCH] Handle Python 3 case where stdout by default is Unicode. --- src/allmydata/scripts/tahoe_get.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/allmydata/scripts/tahoe_get.py b/src/allmydata/scripts/tahoe_get.py index b934f54b8..769a366a5 100644 --- a/src/allmydata/scripts/tahoe_get.py +++ b/src/allmydata/scripts/tahoe_get.py @@ -30,6 +30,10 @@ def get(options): outf = open(to_file, "wb") else: outf = stdout + # Make sure we can write bytes; on Python 3 stdout is Unicode by + # default. + if getattr(outf, "encoding", None) is not None: + outf = outf.buffer while True: data = resp.read(4096) if not data: