summaryrefslogtreecommitdiffstats
path: root/Lib/smtpd.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2013-06-07 14:21:41 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2013-06-07 14:21:41 (GMT)
commit30298b468b1c702bf3082b57fea13247e53e2ae2 (patch)
tree4ea40ceefc58a21b612ee0da3de1a32663f28ca1 /Lib/smtpd.py
parent4e694d6fa9f1fbdf1de137214deceac4cd87e091 (diff)
downloadcpython-30298b468b1c702bf3082b57fea13247e53e2ae2.zip
cpython-30298b468b1c702bf3082b57fea13247e53e2ae2.tar.gz
cpython-30298b468b1c702bf3082b57fea13247e53e2ae2.tar.bz2
Closes #11959: SMTPServer and SMTPChannel now take an optional map, use of which avoids affecting global state.
Diffstat (limited to 'Lib/smtpd.py')
-rwxr-xr-xLib/smtpd.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index 3cab264..f28036a 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -121,8 +121,9 @@ class SMTPChannel(asynchat.async_chat):
})
max_command_size_limit = max(command_size_limits.values())
- def __init__(self, server, conn, addr, data_size_limit=DATA_SIZE_DEFAULT):
- asynchat.async_chat.__init__(self, conn)
+ def __init__(self, server, conn, addr, data_size_limit=DATA_SIZE_DEFAULT,
+ map=None):
+ asynchat.async_chat.__init__(self, conn, map=map)
self.smtp_server = server
self.conn = conn
self.addr = addr
@@ -576,11 +577,11 @@ class SMTPServer(asyncore.dispatcher):
channel_class = SMTPChannel
def __init__(self, localaddr, remoteaddr,
- data_size_limit=DATA_SIZE_DEFAULT):
+ data_size_limit=DATA_SIZE_DEFAULT, map=None):
self._localaddr = localaddr
self._remoteaddr = remoteaddr
self.data_size_limit = data_size_limit
- asyncore.dispatcher.__init__(self)
+ asyncore.dispatcher.__init__(self, map=map)
try:
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
# try to re-use a server port if possible
@@ -597,7 +598,8 @@ class SMTPServer(asyncore.dispatcher):
def handle_accepted(self, conn, addr):
print('Incoming connection from %s' % repr(addr), file=DEBUGSTREAM)
- channel = self.channel_class(self, conn, addr, self.data_size_limit)
+ channel = self.channel_class(self, conn, addr, self.data_size_limit,
+ self._map)
# API for "doing something useful with the message"
def process_message(self, peer, mailfrom, rcpttos, data):