image-download output to stdout fails with Python 3
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Glance Client |
Fix Released
|
Undecided
|
Unassigned | ||
Liberty |
Fix Committed
|
Undecided
|
Flavio Percoco |
Bug Description
When using image-download with Python3 and outputting to stdout, I get the following error:
Traceback (most recent call last):
File "/usr/lib/
args.
File "/usr/lib/
utils.
File "/usr/lib/
image.
TypeError: write() argument must be str, not bytes
This this due to Python 3 requiring a string when printing directly to stdout, whereas Python 2 allowed either string or bytes.
A good description of the issue is documented here:
http://
I think the easiest fix for this is to test for sys.stdout.buffer which should be used for Python 3, then fall back to sys.stdout if it's not available.
I've put up a review to fix this:
https:/
Changed in python-glanceclient: | |
status: | New → Confirmed |
Reviewed: https:/ /review. openstack. org/259825 /git.openstack. org/cgit/ openstack/ python- glanceclient/ commit/ ?id=3caeb4504e7 f96130f904356bf 45f93fcd7834c6
Committed: https:/
Submitter: Jenkins
Branch: master
commit 3caeb4504e7f961 30f904356bf45f9 3fcd7834c6
Author: Andy Botting <email address hidden>
Date: Mon Dec 21 12:18:08 2015 +1100
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: I2963914e2e0744 410267b5735ff77 939413916d4