Ticket #5852: 5852.8.patch

File 5852.8.patch, 2.7 KB (added by rwall, 3 years ago)
  • twisted/mail/smtp.py

    === modified file 'twisted/mail/smtp.py'
     
    88
    99import time, re, base64, types, socket, os, random, rfc822
    1010import binascii
     11import warnings
    1112from email.base64MIME import encode as encode_base64
    1213
    1314from zope.interface import implements, Interface
     
    984985class SMTPClient(basic.LineReceiver, policies.TimeoutMixin):
    985986    """
    986987    SMTP client for sending emails.
    987    
     988
    988989    After the client has connected to the SMTP server, it repeatedly calls
    989990    L{SMTPClient.getMailFrom}, L{SMTPClient.getMailTo} and
    990991    L{SMTPClient.getMailData} and uses this information to send an email.
     
    12461247        self.context = contextFactory
    12471248
    12481249
     1250    def __setattr__(self, name, value):
     1251        if name == "tlsMode":
     1252            warnings.warn(
     1253                "tlsMode attribute of twisted.mail.smtp.ESMTPClient "
     1254                "is deprecated since Twisted 13.0",
     1255                category=DeprecationWarning, stacklevel=2)
     1256        self.__dict__[name] = value
     1257
     1258
    12491259    def esmtpEHLORequired(self, code=-1, resp=None):
    12501260        self.sendError(EHLORequiredError(502, "Server does not support ESMTP Authentication", self.log.str()))
    12511261
     
    16841694
    16851695class SMTPSender(SenderMixin, SMTPClient):
    16861696    """
    1687     SMTP protocol that sends a single email based on information it 
     1697    SMTP protocol that sends a single email based on information it
    16881698    gets from its factory, a L{SMTPSenderFactory}.
    16891699    """
    16901700
  • twisted/mail/test/test_smtp.py

    === modified file 'twisted/mail/test/test_smtp.py'
     
    16111611
    16121612        # The client give up
    16131613        self.assertEqual("QUIT\r\n", transport.value())
     1614
     1615
     1616    def test_esmtpClientTlsModeDeprecation(self):
     1617        """
     1618        L{smtp.ESMTPClient.tlsMode} is deprecated.
     1619        """
     1620        self.clientProtocol.tlsMode = False
     1621        warningsShown = self.flushWarnings(
     1622            offendingFunctions=[self.test_esmtpClientTlsModeDeprecation])
     1623        self.assertEqual(len(warningsShown), 1)
     1624        self.assertIdentical(
     1625            warningsShown[0]['category'], DeprecationWarning)
     1626        self.assertEqual(
     1627            warningsShown[0]['message'],
     1628            "tlsMode attribute of twisted.mail.smtp.ESMTPClient "
     1629            "is deprecated since Twisted 13.0")
  • twisted/mail/topfiles/5852.removal

    === added file 'twisted/mail/topfiles/5852.removal'
     
     1tlsMode attribute of twisted.mail.smtp.ESMTPClient is deprecated.