summaryrefslogtreecommitdiffstats
path: root/Lib/http
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-03 17:32:25 (GMT)
committerGitHub <noreply@github.com>2022-11-03 17:32:25 (GMT)
commitef0e72b31d22f780d3a165d7d0471806061fe380 (patch)
treeb6c37400400dbca49c00466290a60122b6137ae9 /Lib/http
parent9c4ae037b9c39312b792964497c090ce01570208 (diff)
downloadcpython-ef0e72b31d22f780d3a165d7d0471806061fe380.zip
cpython-ef0e72b31d22f780d3a165d7d0471806061fe380.tar.gz
cpython-ef0e72b31d22f780d3a165d7d0471806061fe380.tar.bz2
gh-94172: Remove keyfile, certfile and check_hostname parameters (#94173)
Remove the keyfile, certfile and check_hostname parameters, deprecated since Python 3.6, in modules: ftplib, http.client, imaplib, poplib and smtplib. Use the context parameter (ssl_context in imaplib) instead. Parameters following the removed parameters become keyword-only parameters. ftplib: Remove the FTP_TLS.ssl_version class attribute: use the context parameter instead.
Diffstat (limited to 'Lib/http')
-rw-r--r--Lib/http/client.py25
1 files changed, 3 insertions, 22 deletions
diff --git a/Lib/http/client.py b/Lib/http/client.py
index 0720990..0a3e950 100644
--- a/Lib/http/client.py
+++ b/Lib/http/client.py
@@ -1414,33 +1414,14 @@ else:
default_port = HTTPS_PORT
- # XXX Should key_file and cert_file be deprecated in favour of context?
-
- def __init__(self, host, port=None, key_file=None, cert_file=None,
- timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
- source_address=None, *, context=None,
- check_hostname=None, blocksize=8192):
+ def __init__(self, host, port=None,
+ *, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
+ source_address=None, context=None, blocksize=8192):
super(HTTPSConnection, self).__init__(host, port, timeout,
source_address,
blocksize=blocksize)
- if (key_file is not None or cert_file is not None or
- check_hostname is not None):
- import warnings
- warnings.warn("key_file, cert_file and check_hostname are "
- "deprecated, use a custom context instead.",
- DeprecationWarning, 2)
- self.key_file = key_file
- self.cert_file = cert_file
if context is None:
context = _create_https_context(self._http_vsn)
- if check_hostname is not None:
- context.check_hostname = check_hostname
- if key_file or cert_file:
- context.load_cert_chain(cert_file, key_file)
- # cert and key file means the user wants to authenticate.
- # enable TLS 1.3 PHA implicitly even for custom contexts.
- if context.post_handshake_auth is not None:
- context.post_handshake_auth = True
self._context = context
def connect(self):