Ticket #5852: 5852.6.patch

File 5852.6.patch, 3.4 KB (added by moijes12, 3 years ago)
  • 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
     
    158159        return '\n'.join(res)
    159160
    160161
     162
    161163class ESMTPClientError(SMTPClientError):
    162164    """Base class for ESMTP client errors.
    163165    """
     
    10091011        self.code = -1
    10101012        self.log = util.LineLog(logsize)
    10111013
     1014
    10121015    def sendLine(self, line):
    10131016        # Log sendLine only if you are in debug mode for performance
    10141017        if self.debug:
     
    12441247        self.authenticators = []
    12451248        self.secret = secret
    12461249        self.context = contextFactory
    1247         self.tlsMode = False
    12481250
    12491251
     1252    def __setattr__(self, name, value):
     1253        if name == "tlsMode":
     1254            warnings.warn("tlsMode attribute of twisted.mail.smtp.ESMTPClient is deprecated since Twisted 12.3", category=DeprecationWarning, stacklevel=2)
     1255        self.__dict__[name] = value
     1256
     1257
    12501258    def esmtpEHLORequired(self, code=-1, resp=None):
    12511259        self.sendError(EHLORequiredError(502, "Server does not support ESMTP Authentication", self.log.str()))
    12521260
  • twisted/mail/test/test_smtp.py

     
    66"""
    77
    88from zope.interface import implements
     9import warnings
    910
    1011from twisted.python.util import LineLog
    1112from twisted.trial import unittest, util
    1213from twisted.protocols import basic, loopback
    1314from twisted.mail import smtp
     15from twisted.mail.smtp import ESMTPClient
    1416from twisted.internet import defer, protocol, reactor, interfaces
    1517from twisted.internet import address, error, task
    1618from twisted.test.proto_helpers import StringTransport
     
    609611    def test_loginAuth(self):
    610612        """
    611613        L{ESMTPClient} can authenticate using the I{LOGIN} SASL mechanism.
    612 
     614       
    613615        @see: U{http://sepp.oetiker.ch/sasl-2.1.19-ds/draft-murchison-sasl-login-00.txt}
    614616        """
    615617        realm = DummyRealm()
     
    15181520        client.sentMail(199, "Test response", 1, addresses, client.log)
    15191521
    15201522        return onDone
     1523
     1524
     1525
     1526class DeprecationTests(unittest.TestCase):
     1527    """
     1528    Test for deprecations.
     1529    """
     1530
     1531    def test_esmtpClientTlsModeDeprecation(self):
     1532        """
     1533        Test deprecation of ESMTPClient.tlsMode.
     1534        """
     1535        client = ESMTPClient('', '', '')
     1536        client.tlsMode = False
     1537        warningsShown = self.flushWarnings([self.test_esmtpClientTlsModeDeprecation])
     1538        self.assertEqual(len(warningsShown), 1)
     1539        self.assertIdentical(warningsShown[0]['category'], DeprecationWarning)
     1540        self.assertEqual(warningsShown[0]['message'], "tlsMode attribute of twisted.mail.smtp.ESMTPClient is deprecated since Twisted 12.3")
     1541
     1542    test_esmtpClientTlsModeDeprecation.suppress = []
  • twisted/mail/topfiles/5852.removal

     
     1tlsMode attribute of twisted.mail.smtp.ESMTPClient is deprecated.