Skip to content

Commit

Permalink
Normalize response from the GCE metadata server. (#272)
Browse files Browse the repository at this point in the history
The response is always read in as bytes, and sometimes blindly passed to
things that accept strings. In Python 3, some things that accept strings
(like json.loads) will only accept unicode-type objects, not bytes-type
objects. This change makes sure the bytes are converted to a unicode
string (decoded using the utf-8 codec) in Python 3.
  • Loading branch information
houglum committed Jun 21, 2019
1 parent da8fe1d commit 8c76e8d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion apitools/base/py/credentials_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ def _do_refresh_request(self, unused_http_request):
if self.store:
self.store.locked_put(self)
raise
content = response.read()
content = six.ensure_str(response.read())
try:
credential_info = json.loads(content)
except ValueError:
Expand Down

0 comments on commit 8c76e8d

Please sign in to comment.