-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues with GceAssertionCredentials in Python 3 #254
base: master
Are you sure you want to change the base?
Conversation
CC: @aaltay, @tvalentyn, @markflyhigh |
ebcc7e7
to
2917f22
Compare
2917f22
to
3f3fca1
Compare
Hey @kevinli7, can you please review this change? Thanks! |
There is a test failure under Python 3.5:
|
with mock.patch.object(six.moves.urllib.request, 'build_opener', | ||
return_value=opener, | ||
autospec=True) as build_opener: | ||
creds.GetServiceAccount('default') | ||
creds.GetServiceAccount(b'default') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this might be at fault for the Python 3.5 regression mentioned in this comment.
Maybe something like this would help remedy the regression:
if six.PY2:
creds.GetServiceAccount(b'default')
else:
creds.GetServiceAccount('default')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking this above comment "request changes", sorry I'm still a little new to the github workflow. 🙂
with mock.patch.object(six.moves.urllib.request, 'build_opener', | ||
return_value=opener, | ||
autospec=True) as build_opener: | ||
creds.GetServiceAccount('default') | ||
creds.GetServiceAccount(b'default') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking this above comment "request changes", sorry I'm still a little new to the github workflow. 🙂
@@ -352,7 +352,7 @@ def _ScopesFromMetadataServer(self, scopes): | |||
def GetServiceAccount(self, account): | |||
relative_url = 'instance/service-accounts' | |||
response = _GceMetadataRequest(relative_url) | |||
response_lines = [line.rstrip('/\n\r') | |||
response_lines = [line.rstrip(b'/\n\r').decode('utf-8') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like #271 fixes this Py3 incompatibility, but not the one in _do_refresh_request below.
This change fixes issues with GceAssertionCredentials in Python 3.