From 87eba485330c68ae4c48f7249d20aa566cbe4676 Mon Sep 17 00:00:00 2001 From: David Miller <45697098+dlm6693@users.noreply.github.com> Date: Thu, 22 Sep 2022 18:05:23 -0400 Subject: [PATCH] suppress pyopenssl deprecation warning with catch_warnings (#2763) --- botocore/httpsession.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/botocore/httpsession.py b/botocore/httpsession.py index 29b2103772..d8094a2370 100644 --- a/botocore/httpsession.py +++ b/botocore/httpsession.py @@ -3,6 +3,7 @@ import os.path import socket import sys +import warnings from base64 import b64encode from urllib3 import PoolManager, Timeout, proxy_from_url @@ -37,8 +38,14 @@ from ssl import OP_NO_TICKET, PROTOCOL_TLS_CLIENT try: - # Always import the original SSLContext, even if it has been patched - from urllib3.contrib.pyopenssl import orig_util_SSLContext as SSLContext + # pyopenssl will be removed in urllib3 2.0, we'll fall back to ssl_ at that point. + # This can be removed once our urllib3 floor is raised to >= 2.0. + with warnings.catch_warnings(): + warnings.simplefilter("ignore", category=DeprecationWarning) + # Always import the original SSLContext, even if it has been patched + from urllib3.contrib.pyopenssl import ( + orig_util_SSLContext as SSLContext, + ) except ImportError: from urllib3.util.ssl_ import SSLContext