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 (community) 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
1=== modified file 'lazr/smtptest/docs/NEWS.rst'
2--- lazr/smtptest/docs/NEWS.rst 2015-01-06 02:58:54 +0000
3+++ lazr/smtptest/docs/NEWS.rst 2019-10-24 22:44:30 +0000
4@@ -2,6 +2,13 @@
5 NEWS for lazr.smtptest
6 ======================
7
8+2.0.4
9+=====
10+- Add support for Python 3.6. As of 3.5 (when it became possible), we now
11+ pass the `decode_data=False` parameter when constructing `SMTPChannel` and
12+ `SMTPServer` objects, and handle the new `SMTPServer.process_message`
13+ signature. (LP: #1654334)
14+
15 2.0.3 (2015-01-05)
16 ==================
17 - Always use old-style namespace package registration in ``lazr/__init__.py``
18
19=== modified file 'lazr/smtptest/server.py'
20--- lazr/smtptest/server.py 2015-01-06 02:58:54 +0000
21+++ lazr/smtptest/server.py 2019-10-24 22:44:30 +0000
22@@ -26,10 +26,11 @@
23 ]
24
25
26+import asyncore
27+import logging
28 import smtpd
29 import socket
30-import logging
31-import asyncore
32+import sys
33
34 try:
35 from queue import Empty
36@@ -37,7 +38,10 @@
37 # Python 2
38 from Queue import Empty
39
40-from email import message_from_string
41+if sys.version >= '3.5':
42+ from email import message_from_bytes
43+else:
44+ from email import message_from_string
45
46
47 COMMASPACE = ', '
48@@ -49,7 +53,10 @@
49
50 def __init__(self, server, connection, address):
51 self._server = server
52- smtpd.SMTPChannel.__init__(self, server, connection, address)
53+ kwargs = {}
54+ if sys.version >= '3.5':
55+ kwargs["decode_data"] = False
56+ smtpd.SMTPChannel.__init__(self, server, connection, address, **kwargs)
57
58 def smtp_EXIT(self, argument):
59 """EXIT - a new SMTP command to cleanly stop the server."""
60@@ -96,7 +103,10 @@
61 self.host = host
62 self.port = port
63 self.socket_map = {}
64- smtpd.SMTPServer.__init__(self, (host, port), None)
65+ kwargs = {}
66+ if sys.version >= '3.5':
67+ kwargs['decode_data'] = False
68+ smtpd.SMTPServer.__init__(self, (host, port), None, **kwargs)
69 self.set_reuse_addr()
70 log.info('[SMTPServer] listening: %s:%s', host, port)
71
72@@ -116,11 +126,14 @@
73 log.info('[SMTPServer] accepted: %s', address)
74 Channel(self, connection, address)
75
76- def process_message(self, peer, mailfrom, rcpttos, data):
77+ def process_message(self, peer, mailfrom, rcpttos, data, **kwargs):
78 """Process a received message."""
79 log.info('[SMTPServer] processing: %s, %s, %s, size=%s',
80 peer, mailfrom, rcpttos, len(data))
81- message = message_from_string(data)
82+ if sys.version >= '3.5':
83+ message = message_from_bytes(data)
84+ else:
85+ message = message_from_string(data)
86 message['X-Peer'] = '%s:%s' % (peer[0], peer[1])
87 message['X-MailFrom'] = mailfrom
88 message['X-RcptTo'] = COMMASPACE.join(rcpttos)
89
90=== modified file 'setup.py'
91--- setup.py 2015-01-06 02:58:54 +0000
92+++ setup.py 2019-10-24 22:44:30 +0000
93@@ -50,6 +50,11 @@
94 'Programming Language :: Python :: 2.6',
95 'Programming Language :: Python :: 2.7',
96 'Programming Language :: Python :: 3',
97+ 'Programming Language :: Python :: 3.2',
98+ 'Programming Language :: Python :: 3.3',
99+ 'Programming Language :: Python :: 3.4',
100+ 'Programming Language :: Python :: 3.5',
101+ 'Programming Language :: Python :: 3.6',
102 ],
103 # nose plugins don't really work with `python setup.py test` so use
104 # `python setup.py nosetests` instead, or just `tox`. Gosh, we really
105
106=== modified file 'tox.ini'
107--- tox.ini 2014-08-20 15:58:13 +0000
108+++ tox.ini 2019-10-24 22:44:30 +0000
109@@ -1,5 +1,5 @@
110 [tox]
111-envlist = py27,py32,py33,py34
112+envlist = py27,py32,py33,py34,py35,py36
113
114 [testenv]
115 commands = python setup.py nosetests

Subscribers

People subscribed via source and target branches

to all changes: