From ec87fd2046ef774bcf26f03d890da6144cbb0a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Thu, 7 Dec 2023 12:22:31 +0100 Subject: [PATCH] Fix Python 3.12 patch --- python312.patch | 107 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 74 insertions(+), 33 deletions(-) diff --git a/python312.patch b/python312.patch index 5ee4eee..c9091ab 100644 --- a/python312.patch +++ b/python312.patch @@ -40,7 +40,7 @@ index 868bd5d..3eaf662 100644 self.tree.write() self.tree = HTMLTree(self.doc) diff --git a/awscli/botocore/auth.py b/awscli/botocore/auth.py -index edae233..2483b32 100644 +index edae233..e2536a5 100644 --- a/awscli/botocore/auth.py +++ b/awscli/botocore/auth.py @@ -396,7 +396,7 @@ class SigV4Auth(BaseSigner): @@ -52,6 +52,15 @@ index edae233..2483b32 100644 request.context['timestamp'] = datetime_now.strftime(SIGV4_TIMESTAMP) # This could be a retry. Make sure the previous # authorization header is removed first. +@@ -440,7 +440,7 @@ class SigV4Auth(BaseSigner): + if 'Date' in request.headers: + del request.headers['Date'] + datetime_timestamp = datetime.datetime.strptime( +- request.context['timestamp'], SIGV4_TIMESTAMP) ++ request.context['timestamp'], SIGV4_TIMESTAMP[:-1] + '%z') + request.headers['Date'] = formatdate( + int(calendar.timegm(datetime_timestamp.timetuple()))) + if 'X-Amz-Date' in request.headers: @@ -611,7 +611,7 @@ class S3SigV4PostAuth(SigV4Auth): http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-UsingHTTPPOST.html """ @@ -100,7 +109,7 @@ index 3d1de2f..d8120c6 100644 path=_unicode_path(path)) else: diff --git a/awscli/botocore/crt/auth.py b/awscli/botocore/crt/auth.py -index 534a7f8..474e675 100644 +index 534a7f8..e3337f5 100644 --- a/awscli/botocore/crt/auth.py +++ b/awscli/botocore/crt/auth.py @@ -57,8 +57,7 @@ class CrtSigV4Auth(BaseSigner): @@ -210,7 +219,7 @@ index ffca974..367c867 100644 }, 'ResponseMetadata': { diff --git a/awscli/botocore/signers.py b/awscli/botocore/signers.py -index 77a9346..93b8af0 100644 +index 77a9346..7bbb6cf 100644 --- a/awscli/botocore/signers.py +++ b/awscli/botocore/signers.py @@ -532,7 +532,7 @@ class S3PostPresigner(object): @@ -223,7 +232,7 @@ index 77a9346..93b8af0 100644 policy['expiration'] = expire_date.strftime(botocore.auth.ISO8601) diff --git a/awscli/botocore/utils.py b/awscli/botocore/utils.py -index 81b41dc..0740339 100644 +index 81b41dc..85e5d42 100644 --- a/awscli/botocore/utils.py +++ b/awscli/botocore/utils.py @@ -70,7 +70,7 @@ from botocore.exceptions import ( @@ -235,7 +244,14 @@ index 81b41dc..0740339 100644 from dateutil.tz import tzutc from urllib3.exceptions import LocationParseError -@@ -577,7 +577,7 @@ class InstanceMetadataFetcher(IMDSFetcher): +@@ -571,13 +571,13 @@ class InstanceMetadataFetcher(IMDSFetcher): + return + try: + expiration = datetime.datetime.strptime( +- expiration, "%Y-%m-%dT%H:%M:%SZ" ++ expiration, "%Y-%m-%dT%H:%M:%S%z" + ) + refresh_interval = self._config.get( "ec2_credential_refresh_window", 60 * 10 ) refresh_interval_with_jitter = refresh_interval + random.randint(120, 600) @@ -245,7 +261,7 @@ index 81b41dc..0740339 100644 extension_time = expiration - refresh_offset if current_time >= extension_time: diff --git a/awscli/compat.py b/awscli/compat.py -index 705255d..b418c19 100644 +index 4ea633b..1031356 100644 --- a/awscli/compat.py +++ b/awscli/compat.py @@ -25,6 +25,8 @@ from functools import partial @@ -272,7 +288,7 @@ index 705255d..b418c19 100644 # Most, but not all, python installations will have zlib. This is required to diff --git a/awscli/customizations/cloudformation/deployer.py b/awscli/customizations/cloudformation/deployer.py -index 3733c55..48e69a6 100644 +index 3733c55..8236d33 100644 --- a/awscli/customizations/cloudformation/deployer.py +++ b/awscli/customizations/cloudformation/deployer.py @@ -20,7 +20,7 @@ import collections @@ -294,7 +310,7 @@ index 3733c55..48e69a6 100644 # Each changeset will get a unique name based on time diff --git a/awscli/customizations/cloudtrail/validation.py b/awscli/customizations/cloudtrail/validation.py -index 78e2540..9a515e0 100644 +index 78e2540..ad13507 100644 --- a/awscli/customizations/cloudtrail/validation.py +++ b/awscli/customizations/cloudtrail/validation.py @@ -19,7 +19,7 @@ import re @@ -325,7 +341,7 @@ index 78e2540..9a515e0 100644 raise ParamValidationError( 'Invalid time range specified: start-time must ' diff --git a/awscli/customizations/codecommit.py b/awscli/customizations/codecommit.py -index 6b30e83..935f27b 100644 +index 6b30e83..7859fb8 100644 --- a/awscli/customizations/codecommit.py +++ b/awscli/customizations/codecommit.py @@ -150,7 +150,7 @@ class CodeCommitGetCommand(BasicCommand): @@ -338,7 +354,7 @@ index 6b30e83..935f27b 100644 split = urlsplit(request.url) # we don't want to include the port number in the signature diff --git a/awscli/customizations/codedeploy/push.py b/awscli/customizations/codedeploy/push.py -index 4c08664..8531c03 100644 +index 4c08664..6d97c8c 100644 --- a/awscli/customizations/codedeploy/push.py +++ b/awscli/customizations/codedeploy/push.py @@ -16,7 +16,7 @@ import sys @@ -373,7 +389,7 @@ index ab06305..55f11a9 100644 NOT_SET = '' PREDEFINED_SECTION_NAMES = ('plugins') diff --git a/awscli/customizations/datapipeline/__init__.py b/awscli/customizations/datapipeline/__init__.py -index c47ca94..309406c 100644 +index c47ca94..0c12c39 100644 --- a/awscli/customizations/datapipeline/__init__.py +++ b/awscli/customizations/datapipeline/__init__.py @@ -12,7 +12,7 @@ @@ -395,7 +411,7 @@ index c47ca94..309406c 100644 def build_query(self, parsed_args): diff --git a/awscli/customizations/ec2/bundleinstance.py b/awscli/customizations/ec2/bundleinstance.py -index 96d9ece..31a4962 100644 +index 96d9ece..ad4dca0 100644 --- a/awscli/customizations/ec2/bundleinstance.py +++ b/awscli/customizations/ec2/bundleinstance.py @@ -120,7 +120,7 @@ def _generate_policy(params): @@ -408,7 +424,7 @@ index 96d9ece..31a4962 100644 policy = POLICY.format(expires=expires_iso, bucket=params['Bucket'], diff --git a/awscli/customizations/eks/get_token.py b/awscli/customizations/eks/get_token.py -index c85b86d..4d12661 100644 +index c85b86d..9812be4 100644 --- a/awscli/customizations/eks/get_token.py +++ b/awscli/customizations/eks/get_token.py @@ -16,7 +16,7 @@ import json @@ -430,7 +446,7 @@ index c85b86d..4d12661 100644 ) return token_expiration.strftime('%Y-%m-%dT%H:%M:%SZ') diff --git a/awscli/customizations/logs/tail.py b/awscli/customizations/logs/tail.py -index cb31510..b2f8563 100644 +index cb31510..623e027 100644 --- a/awscli/customizations/logs/tail.py +++ b/awscli/customizations/logs/tail.py @@ -11,7 +11,8 @@ @@ -453,7 +469,7 @@ index cb31510..b2f8563 100644 def to_epoch_millis(self, timestamp): re_match = self._RELATIVE_TIMESTAMP_REGEX.match(timestamp) diff --git a/awscli/customizations/opsworks.py b/awscli/customizations/opsworks.py -index a2a0c1e..217bfca 100644 +index a2a0c1e..ff73132 100644 --- a/awscli/customizations/opsworks.py +++ b/awscli/customizations/opsworks.py @@ -507,7 +507,7 @@ class OpsWorksRegister(BasicCommand): @@ -466,7 +482,7 @@ index a2a0c1e..217bfca 100644 "DateLessThan": { "aws:CurrentTime": diff --git a/tests/functional/botocore/test_credentials.py b/tests/functional/botocore/test_credentials.py -index 843be90..1bd9201 100644 +index 843be90..0349eb4 100644 --- a/tests/functional/botocore/test_credentials.py +++ b/tests/functional/botocore/test_credentials.py @@ -19,7 +19,7 @@ import time @@ -490,7 +506,7 @@ index 843be90..1bd9201 100644 class TestCredentialRefreshRaces(unittest.TestCase): diff --git a/tests/functional/botocore/test_ec2.py b/tests/functional/botocore/test_ec2.py -index 795094e..fed43d2 100644 +index 795094e..3ff22c4 100644 --- a/tests/functional/botocore/test_ec2.py +++ b/tests/functional/botocore/test_ec2.py @@ -86,13 +86,13 @@ class TestCopySnapshotCustomization(BaseSessionTest): @@ -510,7 +526,7 @@ index 795094e..fed43d2 100644 def tearDown(self): super(TestCopySnapshotCustomization, self).tearDown() diff --git a/tests/functional/botocore/test_lex.py b/tests/functional/botocore/test_lex.py -index 7e7f619..eb623ec 100644 +index 7e7f619..dbdf329 100644 --- a/tests/functional/botocore/test_lex.py +++ b/tests/functional/botocore/test_lex.py @@ -11,7 +11,7 @@ @@ -536,7 +552,7 @@ index 7e7f619..eb623ec 100644 with self.http_stubber: self.client.post_content(**params) diff --git a/tests/functional/botocore/test_sts.py b/tests/functional/botocore/test_sts.py -index cdc212a..75b367c 100644 +index cdc212a..a279881 100644 --- a/tests/functional/botocore/test_sts.py +++ b/tests/functional/botocore/test_sts.py @@ -10,7 +10,7 @@ @@ -561,7 +577,7 @@ index cdc212a..75b367c 100644 # There should be no 'content-type' in x-amz-signedheaders diff --git a/tests/functional/ec2/test_bundle_instance.py b/tests/functional/ec2/test_bundle_instance.py -index 5bc3204..7dcc416 100644 +index 5bc3204..67015f0 100644 --- a/tests/functional/ec2/test_bundle_instance.py +++ b/tests/functional/ec2/test_bundle_instance.py @@ -34,7 +34,7 @@ class TestBundleInstance(BaseAWSCommandParamsTest): @@ -609,7 +625,7 @@ index 83f824d..ddefc47 100644 cli_runner.env["AWS_USE_FIPS_ENDPOINT"] = "false" cmdline = [ diff --git a/tests/functional/eks/test_get_token.py b/tests/functional/eks/test_get_token.py -index 89801f9..ea48865 100644 +index 89801f9..cdf51f7 100644 --- a/tests/functional/eks/test_get_token.py +++ b/tests/functional/eks/test_get_token.py @@ -11,7 +11,7 @@ @@ -693,7 +709,7 @@ index 795b939..4562b92 100644 expected = ( diff --git a/tests/functional/s3/test_presign_command.py b/tests/functional/s3/test_presign_command.py -index 2db338a..8b3120a 100644 +index 2db338a..03741d1 100644 --- a/tests/functional/s3/test_presign_command.py +++ b/tests/functional/s3/test_presign_command.py @@ -18,13 +18,13 @@ from awscli.testutils import BaseAWSCommandParamsTest, mock, temporary_file @@ -736,15 +752,19 @@ index d6b0902..4e66fdf 100644 ConnectTimeoutError, ReadTimeoutError, EndpointConnectionError, ConnectionClosedError, ClientError, ProxyConnectionError diff --git a/tests/unit/botocore/auth/test_signers.py b/tests/unit/botocore/auth/test_signers.py -index 73d3b12..3b3922d 100644 +index 73d3b12..25ca21f 100644 --- a/tests/unit/botocore/auth/test_signers.py +++ b/tests/unit/botocore/auth/test_signers.py -@@ -31,7 +31,7 @@ class BaseTestWithFixedDate(unittest.TestCase): - self.fixed_date = datetime.datetime(2014, 3, 10, 17, 2, 55, 0) +@@ -28,10 +28,10 @@ from botocore.awsrequest import AWSRequest + + class BaseTestWithFixedDate(unittest.TestCase): + def setUp(self): +- self.fixed_date = datetime.datetime(2014, 3, 10, 17, 2, 55, 0) ++ self.fixed_date = datetime.datetime(2014, 3, 10, 17, 2, 55, 0, tzinfo=datetime.timezone.utc) self.datetime_patch = mock.patch('botocore.auth.datetime.datetime') self.datetime_mock = self.datetime_patch.start() - self.datetime_mock.utcnow.return_value = self.fixed_date -+ self.datetime_mock.now.return_value = self.fixed_date.replace(tzinfo=datetime.timezone.utc) ++ self.datetime_mock.now.return_value = self.fixed_date self.datetime_mock.strptime.return_value = self.fixed_date def tearDown(self): @@ -829,7 +849,7 @@ index f28b959..1b3d56b 100644 'the ``NextToken`` from a previous response.'), ' :returns: None', diff --git a/tests/unit/botocore/test_credentials.py b/tests/unit/botocore/test_credentials.py -index cc49596..0a5e4d7 100644 +index cc49596..b6b4400 100644 --- a/tests/unit/botocore/test_credentials.py +++ b/tests/unit/botocore/test_credentials.py @@ -11,7 +11,7 @@ @@ -897,7 +917,7 @@ index cc49596..0a5e4d7 100644 # The profile we will be using has a cache entry, but the profile it # is sourcing from does not. This should result in the cached diff --git a/tests/unit/botocore/test_signers.py b/tests/unit/botocore/test_signers.py -index e06e0c1..fc56d71 100644 +index e06e0c1..507e2ea 100644 --- a/tests/unit/botocore/test_signers.py +++ b/tests/unit/botocore/test_signers.py @@ -609,9 +609,9 @@ class TestS3PostPresigner(BaseSignerTest): @@ -922,9 +942,18 @@ index e06e0c1..fc56d71 100644 self.client, hostname, port, username) diff --git a/tests/unit/botocore/test_utils.py b/tests/unit/botocore/test_utils.py -index a4d7f13..97df14b 100644 +index a4d7f13..e7c9af4 100644 --- a/tests/unit/botocore/test_utils.py +++ b/tests/unit/botocore/test_utils.py +@@ -98,7 +98,7 @@ from botocore.stub import Stubber + from botocore.config import Config + from botocore.endpoint_provider import RuleSetEndpoint + +-DATE = datetime.datetime(2021, 12, 10, 00, 00, 00) ++DATE = datetime.datetime(2021, 12, 10, 00, 00, 00, tzinfo=datetime.timezone.utc) + DT_FORMAT = "%Y-%m-%dT%H:%M:%SZ" + + @@ -1004,7 +1004,7 @@ class TestSwitchToChunkedEncodingForNonSeekableObjects(unittest.TestCase): def test_switch_to_chunked_encodeing_for_stream_like_object(self): request = AWSRequest( @@ -956,8 +985,20 @@ index 27fbe1f..b79e173 100644 ' ::', ' waiter.wait(', " bar='string'", +diff --git a/tests/unit/customizations/eks/test_get_token.py b/tests/unit/customizations/eks/test_get_token.py +index 17c07b0..0d1b7fc 100644 +--- a/tests/unit/customizations/eks/test_get_token.py ++++ b/tests/unit/customizations/eks/test_get_token.py +@@ -49,6 +49,6 @@ class TestGetTokenCommand(BaseTokenTest): + cmd = GetTokenCommand(self._session) + timestamp = cmd.get_expiration_time() + try: +- datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%SZ') ++ datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S%z') + except ValueError: + raise ValueError("Incorrect data format, should be %Y-%m-%dT%H:%M:%SZ") diff --git a/tests/unit/customizations/test_opsworks.py b/tests/unit/customizations/test_opsworks.py -index 1471ba9..3e30717 100644 +index 1471ba9..f6816b9 100644 --- a/tests/unit/customizations/test_opsworks.py +++ b/tests/unit/customizations/test_opsworks.py @@ -34,8 +34,8 @@ class TestOpsWorksBase(unittest.TestCase): @@ -972,10 +1013,10 @@ index 1471ba9..3e30717 100644 def tearDown(self): self.datetime_patcher.stop() diff --git a/tests/utils/botocore/__init__.py b/tests/utils/botocore/__init__.py -index 964ec88..2213f96 100644 +index 9b8f205..919bccc 100644 --- a/tests/utils/botocore/__init__.py +++ b/tests/utils/botocore/__init__.py -@@ -555,7 +555,7 @@ class FreezeTime(contextlib.ContextDecorator): +@@ -565,7 +565,7 @@ class FreezeTime(contextlib.ContextDecorator): def __init__(self, module, date=None): if date is None: @@ -984,7 +1025,7 @@ index 964ec88..2213f96 100644 self.date = date self.datetime_patcher = mock.patch.object( module, 'datetime', -@@ -564,7 +564,7 @@ class FreezeTime(contextlib.ContextDecorator): +@@ -574,7 +574,7 @@ class FreezeTime(contextlib.ContextDecorator): def __enter__(self, *args, **kwargs): mock = self.datetime_patcher.start()