Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#55036 closed defect (fixed)

py-twisted @17.5.0: Fix email sending bug

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)
Priority: Normal Milestone:
Component: ports Version:
Keywords: haspatch Cc: mojca (Mojca Miklavec), olv.bonnet@…, l2dy (Zero King)
Port: py-twisted

Description

Email fails to send on the MacPorts buildbot installation, at least in part because we are using py-twisted 17.5.0 from MacPorts which has an email-sending bug:

2017-10-08 17:42:41+0000 [ESMTPSender,client] SMTP Client retrying server. Retry: 1
2017-10-08 17:42:41+0000 [ESMTPSender,client] Unhandled Error
	Traceback (most recent call last):
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/python/log.py", line 103, in callWithLogger
	    return callWithContext({"system": lp}, func, *args, **kw)
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/python/log.py", line 86, in callWithContext
	    return context.call({ILogContext: newCtx}, func, *args, **kw)
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/python/context.py", line 122, in callWithContext
	    return self.currentContext().callWithContext(ctx, func, *args, **kw)
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/python/context.py", line 85, in callWithContext
	    return func(*args,**kw)
	--- <exception caught here> ---
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/internet/selectreactor.py", line 149, in _doReadOrWrite
	    why = getattr(selectable, method)()
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/internet/tcp.py", line 208, in doRead
	    return self._dataReceived(data)
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/internet/tcp.py", line 214, in _dataReceived
	    rval = self.protocol.dataReceived(data)
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/protocols/tls.py", line 330, in dataReceived
	    self._flushReceiveBIO()
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/protocols/tls.py", line 295, in _flushReceiveBIO
	    ProtocolWrapper.dataReceived(self, bytes)
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/protocols/policies.py", line 120, in dataReceived
	    self.wrappedProtocol.dataReceived(data)
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/protocols/basic.py", line 571, in dataReceived
	    why = self.lineReceived(line)
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/mail/smtp.py", line 995, in lineReceived
	    why = self._okresponse(self.code, b'\n'.join(self.resp))
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/mail/smtp.py", line 1044, in smtpState_to
	    return self.smtpState_toOrData(0, b'')
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/mail/smtp.py", line 1062, in smtpState_toOrData
	    self.sendLine(b'RCPT TO:' + quoteaddr(self.lastAddress))
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/mail/smtp.py", line 179, in quoteaddr
	    res = email.utils.parseaddr(addr)
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py", line 214, in parseaddr
	    addrs = _AddressList(addr).addresslist
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/_parseaddr.py", line 457, in __init__
	    self.addresslist = self.getaddrlist()
	  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/_parseaddr.py", line 217, in getaddrlist
	    while self.pos < len(self.field):
	exceptions.TypeError: object of type 'module' has no len()
	

Here is the upstream ticket: https://twistedmatrix.com/trac/ticket/9180

That server is down for me at the moment, but here is the fix upstream committed: https://github.com/twisted/twisted/commit/5ddbe39695f65e2cd485c997fe2af7afdfe4b751

Most of that commit is irrelevant; we probably only need the one-character change changing email to _email. See attached patches.

Alternately, you could update py-twisted to 17.9.0 which includes this fix.

Attachments (2)

py-twisted.diff (721 bytes) - added by ryandesign (Ryan Carsten Schmidt) 7 years ago.
patch-src-twisted-mail-smtp.py.diff (638 bytes) - added by ryandesign (Ryan Carsten Schmidt) 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by ryandesign (Ryan Carsten Schmidt)

Attachment: py-twisted.diff added

Changed 7 years ago by ryandesign (Ryan Carsten Schmidt)

comment:1 Changed 7 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: newclosed

In ef2cd05406bef4ad9f5573d14e5a4308a793831e/macports-ports:

py-twisted: Fix email sending bug

Closes: #55036

comment:2 Changed 7 years ago by l2dy (Zero King)

Cc: l2dy added
Note: See TracTickets for help on using tickets.