yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #47022
[Bug 1550885] [NEW] glance.common.scripts.utils.get_image_data_iter() is not python 3 compatible
Public bug reported:
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.
** Affects: glance
Importance: Undecided
Status: New
--
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:
New
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
Follow ups