Ticket #19134: 19134-with-test.diff

File 19134-with-test.diff, 1.3 KB (added by hongshuning, 3 years ago)
  • django/core/mail/backends/smtp.py

    diff --git a/django/core/mail/backends/smtp.py b/django/core/mail/backends/smtp.py
    index b6f7f56..baffa8f 100644
    a b class EmailBackend(BaseEmailBackend): 
    6363        try:
    6464            try:
    6565                self.connection.quit()
    66             except socket.sslerror:
     66            except (socket.sslerror, smtplib.SMTPServerDisconnected):
    6767                # This happens when calling quit() on a TLS connection
    68                 # sometimes.
     68                # sometimes, or when the connection was already disconnected
     69                # by the server.
    6970                self.connection.close()
    7071            except:
    7172                if self.fail_silently:
  • tests/regressiontests/mail/tests.py

    diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py
    index a8fbf20..061c3f5 100644
    a b class SMTPBackendTests(BaseEmailBackendTests, TestCase): 
    678678
    679679    @classmethod
    680680    def tearDownClass(cls):
     681        # for Ticket #19134
     682        backend = smtp.EmailBackend()
     683        backend.username = None
     684        backend.open()
    681685        cls._settings_override.disable()
    682686        cls.server.stop()
     687        backend.close()
    683688
    684689    def setUp(self):
    685690        super(SMTPBackendTests, self).setUp()
Back to Top