mirror of https://github.com/scrapy/scrapy.git
Remove code for unsupported Twisted. (#6510)
This commit is contained in:
parent
0523e1616d
commit
fcb5ab6cff
|
|
@ -16,10 +16,8 @@ from email.utils import formatdate
|
|||
from io import BytesIO
|
||||
from typing import IO, TYPE_CHECKING, Any
|
||||
|
||||
from twisted import version as twisted_version
|
||||
from twisted.internet import ssl
|
||||
from twisted.internet.defer import Deferred
|
||||
from twisted.python.versions import Version
|
||||
|
||||
from scrapy.utils.misc import arg_to_iter
|
||||
from scrapy.utils.python import to_bytes
|
||||
|
|
@ -217,12 +215,9 @@ class MailSender:
|
|||
"heloFallback": True,
|
||||
"requireAuthentication": False,
|
||||
"requireTransportSecurity": self.smtptls,
|
||||
"hostname": self.smtphost,
|
||||
}
|
||||
|
||||
# Newer versions of twisted require the hostname to use STARTTLS
|
||||
if twisted_version >= Version("twisted", 21, 2, 0):
|
||||
factory_keywords["hostname"] = self.smtphost
|
||||
|
||||
factory = ESMTPSenderFactory(
|
||||
self.smtpuser,
|
||||
self.smtppass,
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@ import unittest
|
|||
from email.charset import Charset
|
||||
from io import BytesIO
|
||||
|
||||
from twisted import version as twisted_version
|
||||
from twisted.internet import defer
|
||||
from twisted.internet._sslverify import ClientTLSOptions
|
||||
from twisted.internet.ssl import ClientContextFactory
|
||||
from twisted.python.versions import Version
|
||||
|
||||
from scrapy.mail import MailSender
|
||||
|
||||
|
|
@ -159,10 +156,7 @@ class MailSenderTest(unittest.TestCase):
|
|||
)
|
||||
|
||||
context = factory.buildProtocol("test@scrapy.org").context
|
||||
if twisted_version >= Version("twisted", 21, 2, 0):
|
||||
self.assertIsInstance(context, ClientTLSOptions)
|
||||
else:
|
||||
self.assertIsInstance(context, ClientContextFactory)
|
||||
self.assertIsInstance(context, ClientTLSOptions)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Reference in New Issue