aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Lib/smtplib.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committerDaniil Cherednik <dcherednik@ydb.tech>2024-02-14 14:26:16 +0000
commit31f2a419764a8ba77c2a970cfc80056c6cd06756 (patch)
treec1995d239eba8571cefc640f6648e1d5dd4ce9e2 /contrib/tools/python3/src/Lib/smtplib.py
parentfe2ef02b38d9c85d80060963b265a1df9f38c3bb (diff)
downloadydb-31f2a419764a8ba77c2a970cfc80056c6cd06756.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Lib/smtplib.py')
-rwxr-xr-xcontrib/tools/python3/src/Lib/smtplib.py47
1 files changed, 8 insertions, 39 deletions
diff --git a/contrib/tools/python3/src/Lib/smtplib.py b/contrib/tools/python3/src/Lib/smtplib.py
index 324a1c19f1..18c91746fd 100755
--- a/contrib/tools/python3/src/Lib/smtplib.py
+++ b/contrib/tools/python3/src/Lib/smtplib.py
@@ -749,14 +749,14 @@ class SMTP:
# We could not login successfully. Return result of last attempt.
raise last_exception
- def starttls(self, keyfile=None, certfile=None, context=None):
+ def starttls(self, *, context=None):
"""Puts the connection to the SMTP server into TLS mode.
If there has been no previous EHLO or HELO command this session, this
method tries ESMTP EHLO first.
If the server supports TLS, this will encrypt the rest of the SMTP
- session. If you provide the keyfile and certfile parameters,
+ session. If you provide the context parameter,
the identity of the SMTP server and client can be checked. This,
however, depends on whether the socket module really checks the
certificates.
@@ -774,19 +774,8 @@ class SMTP:
if resp == 220:
if not _have_ssl:
raise RuntimeError("No SSL support included in this Python")
- 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)
if context is None:
- context = ssl._create_stdlib_context(certfile=certfile,
- keyfile=keyfile)
+ context = ssl._create_stdlib_context()
self.sock = context.wrap_socket(self.sock,
server_hostname=self._host)
self.file = None
@@ -1017,35 +1006,18 @@ if _have_ssl:
compiled with SSL support). If host is not specified, '' (the local
host) is used. If port is omitted, the standard SMTP-over-SSL port
(465) is used. local_hostname and source_address have the same meaning
- as they do in the SMTP class. keyfile and certfile are also optional -
- they can contain a PEM formatted private key and certificate chain file
- for the SSL connection. context also optional, can contain a
- SSLContext, and is an alternative to keyfile and certfile; If it is
- specified both keyfile and certfile must be None.
+ as they do in the SMTP class. context also optional, can contain a
+ SSLContext.
"""
default_port = SMTP_SSL_PORT
def __init__(self, host='', port=0, local_hostname=None,
- keyfile=None, certfile=None,
- timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
+ *, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None, context=None):
- 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
if context is None:
- context = ssl._create_stdlib_context(certfile=certfile,
- keyfile=keyfile)
+ context = ssl._create_stdlib_context()
self.context = context
SMTP.__init__(self, host, port, local_hostname, timeout,
source_address)
@@ -1127,10 +1099,7 @@ if __name__ == '__main__':
toaddrs = prompt("To").split(',')
print("Enter message, end with ^D:")
msg = ''
- while 1:
- line = sys.stdin.readline()
- if not line:
- break
+ while line := sys.stdin.readline():
msg = msg + line
print("Message length is %d" % len(msg))