yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #91807
[Bug 1550885] Re: glance.common.scripts.utils.get_image_data_iter() is not python 3 compatible
I think this was fixed with ab4139e30ca56425fb4f62ebf2d5cb48a0455952 .
Glance has been working with Python 3 for a while now, so I suspect this
is no longer an issue. Feel free to reopen this bug if you think
otherwise.
** Changed in: glance
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1550885
Title:
glance.common.scripts.utils.get_image_data_iter() is not python 3
compatible
Status in Glance:
Fix Released
Bug description:
In Python 3, mode 'rb' should be passed for opening binary files,
while mode 'r' should be used for text files. Using 'r' for binary
files causes decode errors during read().
Also, in Python 3, read() on the file handle returned by
urllib.request.urlopen() returns bytes and not string.
The get_image_data_iter() method takes a URI and either uses open()
with 'r' mode if the URI represents a local file or uses
urllib.request.urlopen() if it does not represent a local file. This
returns incompatible file handles in Python 3 since read() on the
former returns a string while read() on the other returns bytes.
Another issues with this method is that it cannot be used to read
binary local files under python 3. Code that uses this method to read
zip files, e.g., works fine in python2 but fails in python3.
These two issues (incompatible return values and inability to read
binary local files) should be fixed for this method to be useful
under python3.
To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/1550885/+subscriptions
References