Merge lp:~cjwatson/lazr.smtptest/py36 into lp:lazr.smtptest

Proposed by Colin Watson
Status: Merged
Merged at revision: 74
Proposed branch: lp:~cjwatson/lazr.smtptest/py36
Merge into: lp:lazr.smtptest
Diff against target: 115 lines (+33/-8)
4 files modified
lazr/smtptest/docs/NEWS.rst (+7/-0)
lazr/smtptest/server.py (+20/-7)
setup.py (+5/-0)
tox.ini (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/lazr.smtptest/py36
Reviewer Review Type Date Requested Status
Ioana Lasc Approve
LAZR Developers Pending
Review via email: mp+374694@code.launchpad.net

Commit message

Add support for Python 3.6.

Description of the change

As of 3.5 (when it became possible), we now pass the `decode_data=False` parameter when constructing `SMTPChannel` and `SMTPServer` objects, and handle the new `SMTPServer.process_message` signature.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lazr/smtptest/docs/NEWS.rst'
--- lazr/smtptest/docs/NEWS.rst 2015-01-06 02:58:54 +0000
+++ lazr/smtptest/docs/NEWS.rst 2019-10-24 22:44:30 +0000
@@ -2,6 +2,13 @@
2NEWS for lazr.smtptest2NEWS for lazr.smtptest
3======================3======================
44
52.0.4
6=====
7- Add support for Python 3.6. As of 3.5 (when it became possible), we now
8 pass the `decode_data=False` parameter when constructing `SMTPChannel` and
9 `SMTPServer` objects, and handle the new `SMTPServer.process_message`
10 signature. (LP: #1654334)
11
52.0.3 (2015-01-05)122.0.3 (2015-01-05)
6==================13==================
7- Always use old-style namespace package registration in ``lazr/__init__.py``14- Always use old-style namespace package registration in ``lazr/__init__.py``
815
=== modified file 'lazr/smtptest/server.py'
--- lazr/smtptest/server.py 2015-01-06 02:58:54 +0000
+++ lazr/smtptest/server.py 2019-10-24 22:44:30 +0000
@@ -26,10 +26,11 @@
26 ]26 ]
2727
2828
29import asyncore
30import logging
29import smtpd31import smtpd
30import socket32import socket
31import logging33import sys
32import asyncore
3334
34try:35try:
35 from queue import Empty36 from queue import Empty
@@ -37,7 +38,10 @@
37 # Python 238 # Python 2
38 from Queue import Empty39 from Queue import Empty
3940
40from email import message_from_string41if sys.version >= '3.5':
42 from email import message_from_bytes
43else:
44 from email import message_from_string
4145
4246
43COMMASPACE = ', '47COMMASPACE = ', '
@@ -49,7 +53,10 @@
4953
50 def __init__(self, server, connection, address):54 def __init__(self, server, connection, address):
51 self._server = server55 self._server = server
52 smtpd.SMTPChannel.__init__(self, server, connection, address)56 kwargs = {}
57 if sys.version >= '3.5':
58 kwargs["decode_data"] = False
59 smtpd.SMTPChannel.__init__(self, server, connection, address, **kwargs)
5360
54 def smtp_EXIT(self, argument):61 def smtp_EXIT(self, argument):
55 """EXIT - a new SMTP command to cleanly stop the server."""62 """EXIT - a new SMTP command to cleanly stop the server."""
@@ -96,7 +103,10 @@
96 self.host = host103 self.host = host
97 self.port = port104 self.port = port
98 self.socket_map = {}105 self.socket_map = {}
99 smtpd.SMTPServer.__init__(self, (host, port), None)106 kwargs = {}
107 if sys.version >= '3.5':
108 kwargs['decode_data'] = False
109 smtpd.SMTPServer.__init__(self, (host, port), None, **kwargs)
100 self.set_reuse_addr()110 self.set_reuse_addr()
101 log.info('[SMTPServer] listening: %s:%s', host, port)111 log.info('[SMTPServer] listening: %s:%s', host, port)
102112
@@ -116,11 +126,14 @@
116 log.info('[SMTPServer] accepted: %s', address)126 log.info('[SMTPServer] accepted: %s', address)
117 Channel(self, connection, address)127 Channel(self, connection, address)
118128
119 def process_message(self, peer, mailfrom, rcpttos, data):129 def process_message(self, peer, mailfrom, rcpttos, data, **kwargs):
120 """Process a received message."""130 """Process a received message."""
121 log.info('[SMTPServer] processing: %s, %s, %s, size=%s',131 log.info('[SMTPServer] processing: %s, %s, %s, size=%s',
122 peer, mailfrom, rcpttos, len(data))132 peer, mailfrom, rcpttos, len(data))
123 message = message_from_string(data)133 if sys.version >= '3.5':
134 message = message_from_bytes(data)
135 else:
136 message = message_from_string(data)
124 message['X-Peer'] = '%s:%s' % (peer[0], peer[1])137 message['X-Peer'] = '%s:%s' % (peer[0], peer[1])
125 message['X-MailFrom'] = mailfrom138 message['X-MailFrom'] = mailfrom
126 message['X-RcptTo'] = COMMASPACE.join(rcpttos)139 message['X-RcptTo'] = COMMASPACE.join(rcpttos)
127140
=== modified file 'setup.py'
--- setup.py 2015-01-06 02:58:54 +0000
+++ setup.py 2019-10-24 22:44:30 +0000
@@ -50,6 +50,11 @@
50 'Programming Language :: Python :: 2.6',50 'Programming Language :: Python :: 2.6',
51 'Programming Language :: Python :: 2.7',51 'Programming Language :: Python :: 2.7',
52 'Programming Language :: Python :: 3',52 'Programming Language :: Python :: 3',
53 'Programming Language :: Python :: 3.2',
54 'Programming Language :: Python :: 3.3',
55 'Programming Language :: Python :: 3.4',
56 'Programming Language :: Python :: 3.5',
57 'Programming Language :: Python :: 3.6',
53 ],58 ],
54 # nose plugins don't really work with `python setup.py test` so use59 # nose plugins don't really work with `python setup.py test` so use
55 # `python setup.py nosetests` instead, or just `tox`. Gosh, we really60 # `python setup.py nosetests` instead, or just `tox`. Gosh, we really
5661
=== modified file 'tox.ini'
--- tox.ini 2014-08-20 15:58:13 +0000
+++ tox.ini 2019-10-24 22:44:30 +0000
@@ -1,5 +1,5 @@
1[tox]1[tox]
2envlist = py27,py32,py33,py342envlist = py27,py32,py33,py34,py35,py36
33
4[testenv]4[testenv]
5commands = python setup.py nosetests5commands = python setup.py nosetests

Subscribers

People subscribed via source and target branches

to all changes: