commit:     5cc6aa7b4d55969799d8c693ddcc2df81862374b
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat May 22 17:45:30 2021 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat May 22 18:17:58 2021 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5cc6aa7b

dev-python/awscli: Fix python3.9 compatibility

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 ...cli-1.19.47.ebuild => awscli-1.19.47-r1.ebuild} |  4 ++
 dev-python/awscli/files/awscli-1.19.47-py39.patch  | 60 ++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/dev-python/awscli/awscli-1.19.47.ebuild 
b/dev-python/awscli/awscli-1.19.47-r1.ebuild
similarity index 95%
rename from dev-python/awscli/awscli-1.19.47.ebuild
rename to dev-python/awscli/awscli-1.19.47-r1.ebuild
index 73e39dc7c9d..fa290ac9095 100644
--- a/dev-python/awscli/awscli-1.19.47.ebuild
+++ b/dev-python/awscli/awscli-1.19.47-r1.ebuild
@@ -40,6 +40,10 @@ BDEPEND="
 
 S="${WORKDIR}/aws-cli-${PV}"
 
+PATCHES=(
+       "${FILESDIR}"/awscli-1.19.47-py39.patch
+)
+
 python_test() {
        nosetests -vv || die
 }

diff --git a/dev-python/awscli/files/awscli-1.19.47-py39.patch 
b/dev-python/awscli/files/awscli-1.19.47-py39.patch
new file mode 100644
index 00000000000..4d1be8eab6d
--- /dev/null
+++ b/dev-python/awscli/files/awscli-1.19.47-py39.patch
@@ -0,0 +1,60 @@
+From 85361123d2fa12eaedf912c046ffe39aebdd2bad Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgo...@gentoo.org>
+Date: Sat, 22 May 2021 19:42:14 +0200
+Subject: [PATCH] Replace use of deprecated base64.encodestring()
+
+Replace the uses of deprecated base64.encodestring() in favor
+of botocore.compat.encodebytes().  This fixes incompatibility with
+Python 3.9 where the former function has finally been removed.
+---
+ awscli/customizations/ec2/bundleinstance.py  | 4 +++-
+ tests/functional/ec2/test_bundle_instance.py | 4 +++-
+ 2 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/awscli/customizations/ec2/bundleinstance.py 
b/awscli/customizations/ec2/bundleinstance.py
+index f704ec301..775e75718 100644
+--- a/awscli/customizations/ec2/bundleinstance.py
++++ b/awscli/customizations/ec2/bundleinstance.py
+@@ -17,6 +17,8 @@ import hmac
+ import base64
+ import datetime
+ 
++from botocore.compat import encodebytes
++
+ from awscli.compat import six
+ 
+ from awscli.arguments import CustomArgument
+@@ -135,7 +137,7 @@ def _generate_signature(params):
+         policy = base64.b64encode(six.b(policy)).decode('utf-8')
+         new_hmac = hmac.new(sak.encode('utf-8'), digestmod=sha1)
+         new_hmac.update(six.b(policy))
+-        ps = base64.encodestring(new_hmac.digest()).strip().decode('utf-8')
++        ps = encodebytes(new_hmac.digest()).strip().decode('utf-8')
+         params['UploadPolicySignature'] = ps
+         del params['_SAK']
+ 
+diff --git a/tests/functional/ec2/test_bundle_instance.py 
b/tests/functional/ec2/test_bundle_instance.py
+index 3eee363da..ca36d7cd5 100644
+--- a/tests/functional/ec2/test_bundle_instance.py
++++ b/tests/functional/ec2/test_bundle_instance.py
+@@ -17,6 +17,8 @@ import datetime
+ import mock
+ from six.moves import cStringIO
+ 
++from botocore.compat import encodebytes
++
+ import awscli.customizations.ec2.bundleinstance
+ from awscli.compat import six
+ from awscli.testutils import BaseAWSCommandParamsTest
+@@ -70,7 +72,7 @@ class TestBundleInstance(BaseAWSCommandParamsTest):
+ 
+     def test_policy_provided(self):
+         policy = '{"notarealpolicy":true}'
+-        base64policy = 
base64.encodestring(six.b(policy)).strip().decode('utf-8')
++        base64policy = encodebytes(six.b(policy)).strip().decode('utf-8')
+         policy_signature = 'a5SmoLOxoM0MHpOdC25nE7KIafg='
+         args = ' --instance-id i-12345678 --owner-akid AKIAIOSFODNN7EXAMPLE'
+         args += ' --owner-sak wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
+-- 
+2.31.1
+

Reply via email to