Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/boto3/compat.py: 44%
27 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
1# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"). You
4# may not use this file except in compliance with the License. A copy of
5# the License is located at
6#
7# https://aws.amazon.com/apache2.0/
8#
9# or in the "license" file accompanying this file. This file is
10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11# ANY KIND, either express or implied. See the License for the specific
12# language governing permissions and limitations under the License.
13import sys
14import os
15import errno
16import socket
17import warnings
19from boto3.exceptions import PythonDeprecationWarning
21# In python3, socket.error is OSError, which is too general
22# for what we want (i.e FileNotFoundError is a subclass of OSError).
23# In py3 all the socket related errors are in a newly created
24# ConnectionError
25SOCKET_ERROR = ConnectionError
27import collections.abc as collections_abc
30if sys.platform.startswith('win'):
31 def rename_file(current_filename, new_filename):
32 try:
33 os.remove(new_filename)
34 except OSError as e:
35 if not e.errno == errno.ENOENT:
36 # We only want to a ignore trying to remove
37 # a file that does not exist. If it fails
38 # for any other reason we should be propagating
39 # that exception.
40 raise
41 os.rename(current_filename, new_filename)
42else:
43 rename_file = os.rename
46def filter_python_deprecation_warnings():
47 """
48 Invoking this filter acknowledges your runtime will soon be deprecated
49 at which time you will stop receiving all updates to your client.
50 """
51 warnings.filterwarnings(
52 'ignore',
53 message=".*Boto3 will no longer support Python.*",
54 category=PythonDeprecationWarning,
55 module=r".*boto3\.compat"
56 )
59def _warn_deprecated_python():
60 """Use this template for future deprecation campaigns as needed."""
61 py_37_params = {
62 'date': 'December 13, 2023',
63 'blog_link': (
64 'https://aws.amazon.com/blogs/developer/'
65 'python-support-policy-updates-for-aws-sdks-and-tools/'
66 )
67 }
68 deprecated_versions = {
69 # Example template for future deprecations
70 (3, 7): py_37_params,
71 }
72 py_version = sys.version_info[:2]
74 if py_version in deprecated_versions:
75 params = deprecated_versions[py_version]
76 warning = (
77 "Boto3 will no longer support Python {}.{} "
78 "starting {}. To continue receiving service updates, "
79 "bug fixes, and security updates please upgrade to Python 3.8 or "
80 "later. More information can be found here: {}"
81 ).format(py_version[0], py_version[1], params['date'], params['blog_link'])
82 warnings.warn(warning, PythonDeprecationWarning)