summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mailman/config/config.py9
-rw-r--r--src/mailman/core/switchboard.py2
-rw-r--r--src/mailman/handlers/tests/test_recipients.py27
-rw-r--r--src/mailman/handlers/to_digest.py2
-rw-r--r--src/mailman/runners/lmtp.py10
-rw-r--r--src/mailman/runners/tests/test_owner.py2
6 files changed, 24 insertions, 28 deletions
diff --git a/src/mailman/config/config.py b/src/mailman/config/config.py
index c92485176..c6fe2041a 100644
--- a/src/mailman/config/config.py
+++ b/src/mailman/config/config.py
@@ -32,7 +32,7 @@ import sys
from flufl.lock import Lock
from lazr.config import ConfigSchema, as_boolean
-from pkg_resources import resource_filename, resource_string
+from pkg_resources import resource_filename, resource_string as resource_bytes
from six.moves.configparser import ConfigParser, RawConfigParser
from string import Template
from unittest.mock import patch
@@ -114,7 +114,7 @@ class Configuration:
self._config = schema.load(config_file)
if filename is not None:
self.filename = filename
- with open(filename) as user_config:
+ with open(filename, 'r', encoding='utf-8') as user_config:
self.push(filename, user_config.read())
def push(self, config_name, config_string):
@@ -286,9 +286,10 @@ def load_external(path, encoding=None):
if path.startswith('python:'):
resource_path = path[7:]
package, dot, resource = resource_path.rpartition('.')
- config_string = resource_string(package, resource + '.cfg')
+ raw = resource_bytes(package, resource + '.cfg')
+ config_string = raw.decode('utf-8')
else:
- with open(path, 'rb') as fp:
+ with open(path, 'r', encoding='utf-8') as fp:
config_string = fp.read()
if encoding is None:
return config_string
diff --git a/src/mailman/core/switchboard.py b/src/mailman/core/switchboard.py
index d635a12e9..3375aa1dd 100644
--- a/src/mailman/core/switchboard.py
+++ b/src/mailman/core/switchboard.py
@@ -134,7 +134,7 @@ class Switchboard:
data['version'] = config.QFILE_SCHEMA_VERSION
# Filter out volatile entries. Use .keys() so that we can mutate the
# dictionary during the iteration.
- for k in data.keys():
+ for k in list(data):
if k.startswith('_'):
del data[k]
# We have to tell the dequeue() method whether to parse the message
diff --git a/src/mailman/handlers/tests/test_recipients.py b/src/mailman/handlers/tests/test_recipients.py
index 8f2a9d47d..ef2021d2c 100644
--- a/src/mailman/handlers/tests/test_recipients.py
+++ b/src/mailman/handlers/tests/test_recipients.py
@@ -26,14 +26,14 @@ __all__ = [
]
-import six
import unittest
from mailman.app.lifecycle import create_list
from mailman.config import config
from mailman.interfaces.member import DeliveryMode, DeliveryStatus, MemberRole
from mailman.interfaces.usermanager import IUserManager
-from mailman.testing.helpers import specialized_message_from_string as mfs
+from mailman.testing.helpers import (
+ configuration, specialized_message_from_string as mfs)
from mailman.testing.layers import ConfigLayer
from zope.component import getUtility
@@ -200,23 +200,14 @@ To: test-owner@example.com
self._process(self._mlist, self._msg, msgdata)
self.assertEqual(msgdata['recipients'], set(('noreply@example.com',)))
- def test_site_admin_unicode(self):
- # Since the config file is read as bytes, the site_owner is also a
- # bytes and must be converted to unicode when used as a fallback.
+ @configuration('mailman', site_owner='siteadmin@example.com')
+ def test_no_owners_site_owner_fallback(self):
+ # The list has no owners or moderators, but there is a non-default
+ # site owner defined. That owner gets the message.
self._cris.unsubscribe()
self._dave.unsubscribe()
self.assertEqual(self._mlist.administrators.member_count, 0)
msgdata = {}
- # In order to properly mimic the testing environment, use
- # config.push()/config.pop() directly instead of using the
- # configuration() context manager.
- config.push('test_site_admin_unicode', b"""\
-[mailman]
-site_owner: siteadmin@example.com
-""")
- try:
- self._process(self._mlist, self._msg, msgdata)
- finally:
- config.pop('test_site_admin_unicode')
- self.assertEqual(len(msgdata['recipients']), 1)
- self.assertIsInstance(list(msgdata['recipients'])[0], six.text_type)
+ self._process(self._mlist, self._msg, msgdata)
+ self.assertEqual(msgdata['recipients'],
+ set(('siteadmin@example.com',)))
diff --git a/src/mailman/handlers/to_digest.py b/src/mailman/handlers/to_digest.py
index e915bbfa3..9eb5818bb 100644
--- a/src/mailman/handlers/to_digest.py
+++ b/src/mailman/handlers/to_digest.py
@@ -55,7 +55,7 @@ class ToDigest:
mailbox_path = os.path.join(mlist.data_path, 'digest.mmdf')
# Lock the mailbox and append the message.
with Mailbox(mailbox_path, create=True) as mbox:
- mbox.add(msg.as_string())
+ mbox.add(msg)
# Calculate the current size of the mailbox file. This will not tell
# us exactly how big the resulting MIME and rfc1153 digest will
# actually be, but it's the most easily available metric to decide
diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py
index 7560fd962..cb5b4a017 100644
--- a/src/mailman/runners/lmtp.py
+++ b/src/mailman/runners/lmtp.py
@@ -91,7 +91,7 @@ SUBADDRESS_QUEUES = dict(
)
DASH = '-'
-CRLF = b'\r\n'
+CRLF = '\r\n'
ERR_451 = b'451 Requested action aborted: error in processing'
ERR_501 = b'501 Message has defects'
ERR_502 = b'502 Error: command HELO not implemented'
@@ -99,7 +99,7 @@ ERR_550 = b'550 Requested action not taken: mailbox unavailable'
ERR_550_MID = b'550 No Message-ID header provided'
# XXX Blech
-smtpd.__version__ = b'Python LMTP runner 1.0'
+smtpd.__version__ = 'Python LMTP runner 1.0'
@@ -147,6 +147,10 @@ class Channel(smtpd.SMTPChannel):
"""HELO is not a valid LMTP command."""
self.push(ERR_502)
+ ## def push(self, arg):
+ ## import pdb; pdb.set_trace()
+ ## return super().push(arg)
+
class LMTPRunner(Runner, smtpd.SMTPServer):
@@ -243,7 +247,7 @@ class LMTPRunner(Runner, smtpd.SMTPServer):
config.switchboards[queue].enqueue(msg, msgdata)
slog.debug('%s subaddress: %s, queue: %s',
message_id, canonical_subaddress, queue)
- status.append(b'250 Ok')
+ status.append('250 Ok')
except Exception:
slog.exception('Queue detection: %s', msg['message-id'])
config.db.abort()
diff --git a/src/mailman/runners/tests/test_owner.py b/src/mailman/runners/tests/test_owner.py
index 6c68e91cc..503f1e18d 100644
--- a/src/mailman/runners/tests/test_owner.py
+++ b/src/mailman/runners/tests/test_owner.py
@@ -89,7 +89,7 @@ class TestEmailToOwner(unittest.TestCase):
# get a copy of the message.
lmtp = get_lmtp_client(quiet=True)
lmtp.lhlo('remote.example.org')
- lmtp.sendmail('zuzu@example.org', ['test-owner@example.com'], """\
+ lmtp.sendmail('zuzu@example.org', ['test-owner@example.com'], b"""\
From: Zuzu Person <zuzu@example.org>
To: test-owner@example.com
Message-ID: <ant>