File tree Expand file tree Collapse file tree 4 files changed +76
-1
lines changed Expand file tree Collapse file tree 4 files changed +76
-1
lines changed Original file line number Diff line number Diff line change 2222import shlex
2323import re
2424import os
25+ import warnings
2526from collections import OrderedDict
2627from collections .abc import MutableMapping
2728from math import floor
2829
29- from botocore .vendored import six
3030from botocore .exceptions import MD5UnavailableError
3131from dateutil .tz import tzlocal
3232from urllib3 import exceptions
@@ -360,3 +360,23 @@ def has_minimum_crt_version(minimum_version):
360360 HAS_GZIP = True
361361except ImportError :
362362 HAS_GZIP = False
363+
364+
365+ def __getattr__ (name ):
366+ """
367+ Module override to raise warnings when deprecated libraries
368+ are imported in external code.
369+ """
370+ if name == "six" :
371+ warnstr = (
372+ "The botocore.compat.six module is deprecated and will be removed "
373+ "in a future version. Please use six as a direct dependency."
374+ )
375+ warnings .warn (warnstr , DeprecationWarning , stacklevel = 2 )
376+ # The vendored copy of six is deprecated and will be removed in a future version.
377+ with warnings .catch_warnings ():
378+ warnings .simplefilter ("ignore" , DeprecationWarning )
379+ from botocore .vendored import six
380+ return six
381+
382+ raise AttributeError (f"module { __name__ } has no attribute { name } ." )
Original file line number Diff line number Diff line change 2727import operator
2828import sys
2929import types
30+ import warnings
31+
32+ warnstr = (
33+ "The botocore.vendored.six module is deprecated and will be removed "
34+ "in a future version. Please use six as a direct dependency."
35+ )
36+ warnings .warn (warnstr , DeprecationWarning , stacklevel = 2 )
3037
3138__author__ = "Benjamin Peterson <[email protected] >" 3239__version__ = "1.16.0"
Original file line number Diff line number Diff line change 1111# ANY KIND, either express or implied. See the License for the specific
1212# language governing permissions and limitations under the License.
1313import datetime
14+ import warnings
1415
1516import pytest
1617
@@ -225,3 +226,22 @@ def test_has_crt_global(self):
225226 assert HAS_CRT
226227 except ImportError :
227228 assert not HAS_CRT
229+
230+
231+ def test_six_deprecation_warning ():
232+ msg = "The botocore.compat.six module is deprecated"
233+
234+ # Verify import from compat raises a warning
235+ with warnings .catch_warnings (record = True ) as w1 :
236+ from botocore .compat import six
237+ assert any ([warning for warning in w1 if msg in str (warning .message )])
238+
239+ # Verify other imports don't raise a warning
240+ with warnings .catch_warnings (record = True ) as w2 :
241+ from botocore .compat import urlparse
242+ assert not any ([warning for warning in w2 if msg in str (warning .message )])
243+
244+ # Verify direct import of the module doesn't raise a warning
245+ with warnings .catch_warnings (record = True ) as w3 :
246+ import botocore .compat
247+ assert not any ([warning for warning in w3 if msg in str (warning .message )])
Original file line number Diff line number Diff line change 1+ # Copyright 2025 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+ # http://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.
13+
14+ import warnings
15+
16+ def test_six_deprecation_warning ():
17+ msg = "The botocore.vendored.six module is deprecated"
18+
19+ # Verify import from vendored.six raises a warning
20+ with warnings .catch_warnings (record = True ) as w1 :
21+ import botocore .vendored .six
22+ assert any ([warning for warning in w1 if msg in str (warning .message )])
23+
24+ # Verify import of other vendored modules don't raise a warning
25+ with warnings .catch_warnings (record = True ) as w2 :
26+ import botocore .vendored
27+ import botocore .vendored .requests
28+ assert not any ([warning for warning in w2 if msg in str (warning .message )])
You can’t perform that action at this time.
0 commit comments