From 5d280cb772d67e9f0c3eb79029f984b2b9815e1e Mon Sep 17 00:00:00 2001 From: Florent Viard Date: Thu, 19 Jul 2018 01:27:12 +0200 Subject: [PATCH] Fixes #987 - Fixes using IAM with python3. Config options should be unicode. --- S3/Config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/S3/Config.py b/S3/Config.py index e6e76f0ba..10390cbc3 100644 --- a/S3/Config.py +++ b/S3/Config.py @@ -263,10 +263,10 @@ def role_config(self): conn.request('GET', "/latest/meta-data/iam/security-credentials/%s"%files.decode('UTF-8')) resp=conn.getresponse() if resp.status == 200: - creds=json.load(resp) - Config().update_option('access_key', creds['AccessKeyId'].encode('ascii')) - Config().update_option('secret_key', creds['SecretAccessKey'].encode('ascii')) - Config().update_option('access_token', creds['Token'].encode('ascii')) + creds=json.load(resp, encoding="utf-8") + Config().update_option('access_key', config_unicodise(creds['AccessKeyId'])) + Config().update_option('secret_key', config_unicodise(creds['SecretAccessKey'])) + Config().update_option('access_token', config_unicodise(creds['Token'])) else: raise IOError else: