Skip to content

Commit

Permalink
add disable env and set category to FutureWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
David Miller committed Jun 21, 2022
1 parent 0ef3878 commit 55848b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion botocore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
import logging
import os
import warnings

from botocore import waiter, xform_name
Expand Down Expand Up @@ -609,13 +610,17 @@ def _create_endpoint(
if endpoint_url is None:
sslCommonName = resolved.get('sslCommonName')
hostname = resolved.get('hostname')
if sslCommonName is not None:
disable = ensure_boolean(
os.environ.get('BOTO_EXPERIMENTAL__DISABLE_COMMONNAME', '')
)
if not disable and sslCommonName is not None:
warnings.warn(
f'The {service_name} client is currently using a '
f'deprecated endpoint: {sslCommonName}. In the next '
f'minor version this will be moved to {hostname}. '
'See https://github.com/boto/botocore/issues/2376 '
'for more details.',
category=FutureWarning,
)
hostname = sslCommonName
endpoint_url = self._make_url(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ def test_client_close_context_manager(self):
def test_sslCommonName_warning(self):
creator = self.create_client_creator()
self.endpoint_data['sslCommonName'] = 'bar'
with self.assertWarns(UserWarning) as warning:
with self.assertWarns(FutureWarning) as warning:
creator.create_client(
'myservice', 'us-west-2', credentials=self.credentials
)
Expand Down

0 comments on commit 55848b5

Please sign in to comment.