From: R David Murray Date: Sat, 30 Aug 2014 20:55:45 +0000 (-0400) Subject: Merge #22215: have the smtplib 'quit' command reset the state. X-Git-Tag: v3.5.0a1~991 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b10be1550850f82e3dc716b8bf2dea4a85c963d7;p=python Merge #22215: have the smtplib 'quit' command reset the state. --- b10be1550850f82e3dc716b8bf2dea4a85c963d7 diff --cc Lib/test/test_smtplib.py index 816ed83d27,95a9dbe912..5f12d28eea --- a/Lib/test/test_smtplib.py +++ b/Lib/test/test_smtplib.py @@@ -857,25 -855,24 +857,40 @@@ class SMTPSimTests(unittest.TestCase) smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15) try: smtp.login(sim_auth[0], sim_auth[1]) except smtplib.SMTPAuthenticationError as err: - self.assertIn(sim_auth_login_password, str(err)) + self.assertIn(sim_auth_login_user, str(err)) + smtp.close() + + def test_auth_function(self): + smtp = smtplib.SMTP(HOST, self.port, + local_hostname='localhost', timeout=15) + self.serv.add_feature("AUTH CRAM-MD5") + smtp.user, smtp.password = sim_auth[0], sim_auth[1] + supported = {'CRAM-MD5': smtp.auth_cram_md5, + 'PLAIN': smtp.auth_plain, + 'LOGIN': smtp.auth_login, + } + for mechanism, method in supported.items(): + try: smtp.auth(mechanism, method) + except smtplib.SMTPAuthenticationError as err: + self.assertIn(sim_auth_credentials[mechanism.lower()].upper(), + str(err)) smtp.close() + def test_quit_resets_greeting(self): + smtp = smtplib.SMTP(HOST, self.port, + local_hostname='localhost', + timeout=15) + code, message = smtp.ehlo() + self.assertEqual(code, 250) + self.assertIn('size', smtp.esmtp_features) + smtp.quit() + self.assertNotIn('size', smtp.esmtp_features) + smtp.connect(HOST, self.port) + self.assertNotIn('size', smtp.esmtp_features) + smtp.ehlo_or_helo_if_needed() + self.assertIn('size', smtp.esmtp_features) + smtp.quit() + def test_with_statement(self): with smtplib.SMTP(HOST, self.port) as smtp: code, message = smtp.noop() diff --cc Misc/NEWS index 9a27b5ddd1,5111b8aa16..d0e3d7293a --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -124,10 -27,10 +124,14 @@@ Core and Builtin Library ------- + - Issue #22216: smtplib now resets its state more completely after a quit. The + most obvious consequence of the previous behavior was a STARTTLS failure + during a connect/starttls/quit/connect/starttls sequence. + +- Issue #22098: ctypes' BigEndianStructure and LittleEndianStructure now + define an empty __slots__ so that subclasses don't always get an instance + dict. Patch by Claudiu Popa. + - Issue #22185: Fix an occasional RuntimeError in threading.Condition.wait() caused by mutation of the waiters queue without holding the lock. Patch by Doug Zongker.