@@ -250,7 +250,9 @@ def __init__(self, scopes=None, service_account_name='default', **kwds):
250250 # identified these scopes in the same execution. However, the
251251 # available scopes don't change once an instance is created,
252252 # so there is no reason to perform more than one query.
253- self .__service_account_name = service_account_name
253+ self .__service_account_name = six .ensure_text (
254+ service_account_name ,
255+ encoding = 'utf-8' ,)
254256 cached_scopes = None
255257 cache_filename = kwds .get ('cache_filename' )
256258 if cache_filename :
@@ -317,7 +319,8 @@ def _WriteCacheFile(self, cache_filename, scopes):
317319 scopes: Scopes for the desired credentials.
318320 """
319321 # Credentials metadata dict.
320- creds = {'scopes' : sorted (list (scopes )),
322+ scopes = sorted ([six .ensure_text (scope ) for scope in scopes ])
323+ creds = {'scopes' : scopes ,
321324 'svc_acct_name' : self .__service_account_name }
322325 creds_str = json .dumps (creds )
323326 cache_file = _MultiProcessCacheFile (cache_filename )
@@ -352,7 +355,7 @@ def _ScopesFromMetadataServer(self, scopes):
352355 def GetServiceAccount (self , account ):
353356 relative_url = 'instance/service-accounts'
354357 response = _GceMetadataRequest (relative_url )
355- response_lines = [line .rstrip ('/\n \r ' )
358+ response_lines = [six . ensure_text ( line ) .rstrip (u '/\n \r ' )
356359 for line in response .readlines ()]
357360 return account in response_lines
358361
0 commit comments