Ticket #5852: 5852.4.patch

File 5852.4.patch, 3.2 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:
     
    12471250        self.tlsMode = False
    12481251
    12491252
     1253    def __setattr__(self, name, value):
     1254        if name == "tlsMode":
     1255            warnings.warn("twisted.mail.smtp.ESMTPClient is deprecated since Twisted 12.2", category=DeprecationWarning, stacklevel=2)
     1256        self.__dict__[name] = value
     1257
     1258
    12501259    def esmtpEHLORequired(self, code=-1, resp=None):
    12511260        self.sendError(EHLORequiredError(502, "Server does not support ESMTP Authentication", self.log.str()))
    12521261
  • 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
     1532    def test_esmtpClientTlsModeDeprecation(self):
     1533        """
     1534        Test deprecation of ESMTPClient.tlsMode.
     1535        """
     1536        client = ESMTPClient('', '', '')
     1537        warningsShown = self.flushWarnings()
     1538        self.assertEqual(len(warningsShown), 1)
     1539        self.assertIdentical(warningsShown[0]['category'], DeprecationWarning)
     1540        self.assertEqual(warningsShown[0]['message'],
     1541             "twisted.mail.smtp.ESMTPClient is deprecated since Twisted 12.2")
     1542
     1543    test_esmtpClientTlsModeDeprecation.suppress = []
  • twisted/mail/topfiles/5852.removal

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