summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Botting <andy@andybotting.com>2015-12-21 12:18:08 +1100
committerAndy Botting <andy@andybotting.com>2015-12-22 14:42:15 +1100
commit3caeb4504e7f96130f904356bf45f93fcd7834c6 (patch)
treec4fe0669978105dc73f7764f783dab103824d9f3
parentb9a4621b2dc1eacae8bc5cf406bf5b7464e491e3 (diff)
downloadpython-glanceclient-3caeb4504e7f96130f904356bf45f93fcd7834c6.tar.gz
Fix image-download to stdout on Python 3.x
Glance image-download to stdout fails on Python3 due to sys.stdout.write not allowing bytes to be written directly. A good description of the issue is listed at http://bugs.python.org/issue18512 Closes-Bug: #1528083 Change-Id: I2963914e2e0744410267b5735ff77939413916d4
-rw-r--r--glanceclient/common/utils.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/glanceclient/common/utils.py b/glanceclient/common/utils.py
index 88144ef..e7c0992 100644
--- a/glanceclient/common/utils.py
+++ b/glanceclient/common/utils.py
@@ -298,7 +298,10 @@ def save_image(data, path):
:param path: path to save the image to
"""
if path is None:
- image = sys.stdout
+ if six.PY3:
+ image = sys.stdout.buffer
+ else:
+ image = sys.stdout
else:
image = open(path, 'wb')
try: