mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Update smtplib.py to 3.14.5 (#7850)
This commit is contained in:
2
Lib/smtplib.py
vendored
2
Lib/smtplib.py
vendored
@@ -251,7 +251,6 @@ class SMTP:
|
||||
will be used.
|
||||
|
||||
"""
|
||||
self._host = host
|
||||
self.timeout = timeout
|
||||
self.esmtp_features = {}
|
||||
self.command_encoding = 'ascii'
|
||||
@@ -342,6 +341,7 @@ class SMTP:
|
||||
port = int(port)
|
||||
except ValueError:
|
||||
raise OSError("nonnumeric port")
|
||||
self._host = host
|
||||
if not port:
|
||||
port = self.default_port
|
||||
sys.audit("smtplib.connect", self, host, port)
|
||||
|
||||
53
Lib/test/test_smtpnet.py
vendored
53
Lib/test/test_smtpnet.py
vendored
@@ -45,6 +45,59 @@ class SmtpTest(unittest.TestCase):
|
||||
server.ehlo()
|
||||
server.quit()
|
||||
|
||||
def test_connect_host_port_starttls(self):
|
||||
support.get_attribute(smtplib, 'SMTP_SSL')
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||
context.check_hostname = False
|
||||
context.verify_mode = ssl.CERT_NONE
|
||||
with socket_helper.transient_internet(self.testServer):
|
||||
server = smtplib.SMTP(f'{self.testServer}:{self.remotePort}')
|
||||
try:
|
||||
server.starttls(context=context)
|
||||
except smtplib.SMTPException as e:
|
||||
if e.args[0] == 'STARTTLS extension not supported by server.':
|
||||
unittest.skip(e.args[0])
|
||||
else:
|
||||
raise
|
||||
server.ehlo()
|
||||
server.quit()
|
||||
|
||||
def test_explicit_connect_starttls(self):
|
||||
support.get_attribute(smtplib, 'SMTP_SSL')
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||
context.check_hostname = False
|
||||
context.verify_mode = ssl.CERT_NONE
|
||||
with socket_helper.transient_internet(self.testServer):
|
||||
server = smtplib.SMTP()
|
||||
server.connect(self.testServer, self.remotePort)
|
||||
try:
|
||||
server.starttls(context=context)
|
||||
except smtplib.SMTPException as e:
|
||||
if e.args[0] == 'STARTTLS extension not supported by server.':
|
||||
unittest.skip(e.args[0])
|
||||
else:
|
||||
raise
|
||||
server.ehlo()
|
||||
server.quit()
|
||||
|
||||
def test_explicit_connect_host_port_starttls(self):
|
||||
support.get_attribute(smtplib, 'SMTP_SSL')
|
||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
||||
context.check_hostname = False
|
||||
context.verify_mode = ssl.CERT_NONE
|
||||
with socket_helper.transient_internet(self.testServer):
|
||||
server = smtplib.SMTP()
|
||||
server.connect(f'{self.testServer}:{self.remotePort}')
|
||||
try:
|
||||
server.starttls(context=context)
|
||||
except smtplib.SMTPException as e:
|
||||
if e.args[0] == 'STARTTLS extension not supported by server.':
|
||||
unittest.skip(e.args[0])
|
||||
else:
|
||||
raise
|
||||
server.ehlo()
|
||||
server.quit()
|
||||
|
||||
|
||||
class SmtpSSLTest(unittest.TestCase):
|
||||
testServer = SMTP_TEST_SERVER
|
||||
|
||||
Reference in New Issue
Block a user