summaryrefslogtreecommitdiffstats
path: root/Lib/ftplib.py
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/ftplib.py
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/ftplib.py')
-rw-r--r--Lib/ftplib.py24
1 files changed, 4 insertions, 20 deletions
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index dc9a8af..c7ca8f6 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -713,28 +713,12 @@ else:
'221 Goodbye.'
>>>
'''
- ssl_version = ssl.PROTOCOL_TLS_CLIENT
def __init__(self, host='', user='', passwd='', acct='',
- keyfile=None, certfile=None, context=None,
- timeout=_GLOBAL_DEFAULT_TIMEOUT, source_address=None, *,
- encoding='utf-8'):
- if context is not None and keyfile is not None:
- raise ValueError("context and keyfile arguments are mutually "
- "exclusive")
- if context is not None and certfile is not None:
- raise ValueError("context and certfile arguments are mutually "
- "exclusive")
- if keyfile is not None or certfile is not None:
- import warnings
- warnings.warn("keyfile and certfile are deprecated, use a "
- "custom context instead", DeprecationWarning, 2)
- self.keyfile = keyfile
- self.certfile = certfile
+ *, context=None, timeout=_GLOBAL_DEFAULT_TIMEOUT,
+ source_address=None, encoding='utf-8'):
if context is None:
- context = ssl._create_stdlib_context(self.ssl_version,
- certfile=certfile,
- keyfile=keyfile)
+ context = ssl._create_stdlib_context()
self.context = context
self._prot_p = False
super().__init__(host, user, passwd, acct,
@@ -749,7 +733,7 @@ else:
'''Set up secure control connection by using TLS/SSL.'''
if isinstance(self.sock, ssl.SSLSocket):
raise ValueError("Already using TLS")
- if self.ssl_version >= ssl.PROTOCOL_TLS:
+ if self.context.protocol >= ssl.PROTOCOL_TLS:
resp = self.voidcmd('AUTH TLS')
else:
resp = self.voidcmd('AUTH SSL')