From 415b48056d9d021e04ec972029040a89a6b13928 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Thu, 7 Jun 2018 16:40:58 -0700 Subject: Before writing object data to stdout, re-open it in binary mode Otherwise, you can hit TypeErrors on Python3. Change-Id: I9a891508886feddac3982ce593bd95130392e035 Closes-Bug: 1775482 --- openstackclient/api/object_store_v1.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'openstackclient/api') diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py index 31033525..d1e5dfaf 100644 --- a/openstackclient/api/object_store_v1.py +++ b/openstackclient/api/object_store_v1.py @@ -378,8 +378,9 @@ class APIv1(api.BaseAPI): ) if response.status_code == 200: if file == '-': - for chunk in response.iter_content(64 * 1024): - sys.stdout.write(chunk) + with os.fdopen(sys.stdout.fileno(), 'wb') as f: + for chunk in response.iter_content(64 * 1024): + f.write(chunk) else: if not os.path.exists(os.path.dirname(file)): if len(os.path.dirname(file)) > 0: -- cgit v1.2.1