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
This commit is contained in:
Tim Burke
2018-06-07 16:40:58 -07:00
committed by Dean Troyer
parent c53de3214e
commit 415b48056d
3 changed files with 29 additions and 4 deletions

View File

@@ -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: