From d4d71f71f08d6d440b17482eecc5472dcfe6cbae Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 28 Apr 2014 11:23:35 -0400 Subject: Use print functions consistently through, and update all __future__ imports to reflect this. Also, mock out sys.stderr on some tests so that their nose2 output is quieter. A few other minor coding style consistencies. --- src/mailman/__init__.py | 3 +- src/mailman/app/commands.py | 2 +- src/mailman/app/docs/bounces.rst | 4 +- src/mailman/app/docs/chains.rst | 36 ++++++------ src/mailman/app/docs/hooks.rst | 18 +++--- src/mailman/app/docs/lifecycle.rst | 6 +- src/mailman/app/docs/message.rst | 8 +-- src/mailman/app/docs/moderator.rst | 46 +++++++-------- src/mailman/app/docs/pipelines.rst | 10 ++-- src/mailman/app/docs/subscriptions.rst | 4 +- src/mailman/app/docs/system.rst | 2 +- src/mailman/app/domain.py | 2 +- src/mailman/app/events.py | 2 +- src/mailman/app/lifecycle.py | 2 +- src/mailman/app/moderator.py | 2 +- src/mailman/app/replybot.py | 2 +- src/mailman/archiving/docs/common.rst | 28 ++++----- src/mailman/bin/bumpdigests.py | 4 +- src/mailman/bin/checkdbs.py | 2 +- src/mailman/bin/docs/master.rst | 2 +- src/mailman/bin/master.py | 4 +- src/mailman/bin/onebounce.py | 4 +- src/mailman/bin/runner.py | 7 ++- src/mailman/bin/tests/test_master.py | 2 +- src/mailman/chains/accept.py | 2 +- src/mailman/chains/discard.py | 2 +- src/mailman/chains/docs/moderation.rst | 18 +++--- src/mailman/chains/reject.py | 2 +- src/mailman/chains/tests/test_hold.py | 3 +- src/mailman/commands/docs/aliases.rst | 6 +- src/mailman/commands/docs/control.rst | 2 +- src/mailman/commands/docs/create.rst | 6 +- src/mailman/commands/docs/echo.rst | 10 ++-- src/mailman/commands/docs/end.rst | 16 +++--- src/mailman/commands/docs/help.rst | 18 +++--- src/mailman/commands/docs/import.rst | 6 +- src/mailman/commands/docs/info.rst | 2 +- src/mailman/commands/docs/inject.rst | 12 ++-- src/mailman/commands/docs/members.rst | 10 ++-- src/mailman/commands/docs/membership.rst | 78 +++++++++++++------------- src/mailman/commands/docs/remove.rst | 4 +- src/mailman/commands/docs/unshunt.rst | 4 +- src/mailman/commands/docs/withlist.rst | 6 +- src/mailman/commands/tests/test_control.py | 5 +- src/mailman/commands/tests/test_create.py | 3 +- src/mailman/config/__init__.py | 2 +- src/mailman/config/tests/test_configuration.py | 7 ++- src/mailman/core/chains.py | 2 +- src/mailman/core/docs/runner.rst | 2 +- src/mailman/core/docs/switchboard.rst | 8 +-- src/mailman/core/errors.py | 2 +- src/mailman/core/i18n.py | 2 +- src/mailman/core/logging.py | 2 +- src/mailman/core/rules.py | 2 +- src/mailman/database/docs/migration.rst | 24 ++++---- src/mailman/database/types.py | 2 +- src/mailman/docs/__init__.py | 2 +- src/mailman/email/message.py | 2 +- src/mailman/handlers/docs/ack-headers.rst | 4 +- src/mailman/handlers/docs/acknowledge.rst | 4 +- src/mailman/handlers/docs/archives.rst | 4 +- src/mailman/handlers/docs/avoid-duplicates.rst | 14 ++--- src/mailman/handlers/docs/cleanse.rst | 6 +- src/mailman/handlers/docs/cook-headers.rst | 12 ++-- src/mailman/handlers/docs/decorate.rst | 48 ++++++++-------- src/mailman/handlers/docs/digests.rst | 2 +- src/mailman/handlers/docs/file-recips.rst | 14 ++--- src/mailman/handlers/docs/filtering.rst | 18 +++--- src/mailman/handlers/docs/nntp.rst | 2 +- src/mailman/handlers/docs/reply-to.rst | 12 ++-- src/mailman/handlers/docs/replybot.rst | 32 +++++------ src/mailman/handlers/docs/rfc-2369.rst | 6 +- src/mailman/handlers/docs/subject-munging.rst | 32 +++++------ src/mailman/handlers/docs/tagger.rst | 16 +++--- src/mailman/handlers/docs/to-outgoing.rst | 2 +- src/mailman/interfaces/autorespond.py | 2 +- src/mailman/interfaces/bounce.py | 2 +- src/mailman/interfaces/chain.py | 2 +- src/mailman/interfaces/command.py | 2 +- src/mailman/interfaces/digests.py | 2 +- src/mailman/interfaces/domain.py | 2 +- src/mailman/interfaces/errors.py | 2 +- src/mailman/interfaces/languages.py | 2 +- src/mailman/interfaces/listmanager.py | 2 +- src/mailman/interfaces/member.py | 2 +- src/mailman/interfaces/messages.py | 2 +- src/mailman/interfaces/mime.py | 2 +- src/mailman/interfaces/mlistrequest.py | 2 +- src/mailman/interfaces/mta.py | 2 +- src/mailman/interfaces/pending.py | 2 +- src/mailman/interfaces/permissions.py | 2 +- src/mailman/interfaces/pipeline.py | 2 +- src/mailman/interfaces/preferences.py | 2 +- src/mailman/interfaces/registrar.py | 2 +- src/mailman/interfaces/requests.py | 2 +- src/mailman/interfaces/roster.py | 2 +- src/mailman/interfaces/rules.py | 2 +- src/mailman/interfaces/runner.py | 2 +- src/mailman/interfaces/styles.py | 2 +- src/mailman/interfaces/subscriptions.py | 2 +- src/mailman/interfaces/switchboard.py | 2 +- src/mailman/interfaces/system.py | 2 +- src/mailman/interfaces/usermanager.py | 2 +- src/mailman/model/docs/addresses.rst | 38 ++++++------- src/mailman/model/docs/autorespond.rst | 2 +- src/mailman/model/docs/bounce.rst | 16 +++--- src/mailman/model/docs/domains.rst | 22 ++++---- src/mailman/model/docs/languages.rst | 20 +++---- src/mailman/model/docs/listmanager.rst | 24 ++++---- src/mailman/model/docs/mailinglist.rst | 24 ++++---- src/mailman/model/docs/membership.rst | 28 ++++----- src/mailman/model/docs/messagestore.rst | 16 +++--- src/mailman/model/docs/mlist-addresses.rst | 26 ++++----- src/mailman/model/docs/pending.rst | 8 +-- src/mailman/model/docs/registration.rst | 22 ++++---- src/mailman/model/docs/requests.rst | 14 ++--- src/mailman/model/docs/usermanager.rst | 16 +++--- src/mailman/model/docs/users.rst | 36 ++++++------ src/mailman/model/tests/test_domain.py | 2 +- src/mailman/model/tests/test_uid.py | 2 +- src/mailman/model/tests/test_user.py | 2 +- src/mailman/mta/bulk.py | 2 +- src/mailman/mta/connection.py | 2 +- src/mailman/mta/decorating.py | 2 +- src/mailman/mta/deliver.py | 2 +- src/mailman/mta/docs/authentication.rst | 2 +- src/mailman/mta/docs/bulk.rst | 24 ++++---- src/mailman/mta/docs/connection.rst | 4 +- src/mailman/mta/docs/decorating.rst | 16 +++--- src/mailman/mta/docs/personalized.rst | 12 ++-- src/mailman/mta/docs/verp.rst | 6 +- src/mailman/mta/personalized.py | 2 +- src/mailman/mta/tests/test_aliases.py | 2 +- src/mailman/mta/verp.py | 2 +- src/mailman/options.py | 2 +- src/mailman/rest/addresses.py | 2 +- src/mailman/rest/docs/__init__.py | 2 +- src/mailman/rest/docs/basic.rst | 4 +- src/mailman/rest/docs/configuration.rst | 6 +- src/mailman/rest/docs/helpers.rst | 18 +++--- src/mailman/rest/docs/lists.rst | 4 +- src/mailman/rest/docs/membership.rst | 4 +- src/mailman/rest/docs/moderation.rst | 10 ++-- src/mailman/rest/domains.py | 2 +- src/mailman/rest/helpers.py | 2 +- src/mailman/rest/lists.py | 2 +- src/mailman/rest/members.py | 2 +- src/mailman/rest/preferences.py | 2 +- src/mailman/rest/root.py | 2 +- src/mailman/rest/tests/test_root.py | 2 +- src/mailman/rest/users.py | 2 +- src/mailman/rest/validator.py | 2 +- src/mailman/rules/docs/administrivia.rst | 2 +- src/mailman/rules/docs/approved.rst | 18 +++--- src/mailman/rules/docs/header-matching.rst | 16 +++--- src/mailman/rules/docs/implicit-dest.rst | 2 +- src/mailman/rules/docs/loop.rst | 2 +- src/mailman/rules/docs/max-size.rst | 2 +- src/mailman/rules/docs/moderation.rst | 8 +-- src/mailman/rules/docs/news-moderation.rst | 2 +- src/mailman/rules/docs/no-subject.rst | 2 +- src/mailman/rules/docs/recipients.rst | 2 +- src/mailman/rules/docs/rules.rst | 4 +- src/mailman/rules/docs/suspicious.rst | 2 +- src/mailman/runners/digest.py | 58 +++++++++---------- src/mailman/runners/docs/command.rst | 14 ++--- src/mailman/runners/docs/digester.rst | 10 ++-- src/mailman/runners/docs/incoming.rst | 28 ++++----- src/mailman/runners/docs/lmtp.rst | 4 +- src/mailman/runners/docs/nntp.rst | 2 +- src/mailman/runners/docs/outgoing.rst | 4 +- src/mailman/runners/rest.py | 2 +- src/mailman/runners/retry.py | 2 +- src/mailman/runners/tests/test_outgoing.py | 2 +- src/mailman/runners/tests/test_retry.py | 2 +- src/mailman/styles/docs/styles.rst | 18 +++--- src/mailman/testing/documentation.py | 21 +++---- src/mailman/testing/i18n.py | 2 +- src/mailman/tests/test_configfile.py | 14 ++--- src/mailman/utilities/datetime.py | 2 +- src/mailman/utilities/email.py | 2 +- src/mailman/utilities/filesystem.py | 2 +- src/mailman/utilities/interact.py | 2 +- src/mailman/utilities/mailbox.py | 2 +- src/mailman/utilities/modules.py | 2 +- src/mailman/utilities/string.py | 2 +- src/mailman/utilities/tests/test_import.py | 23 ++++++-- src/mailman/utilities/tests/test_wrap.py | 2 +- src/mailman/utilities/uid.py | 2 +- 189 files changed, 765 insertions(+), 747 deletions(-) diff --git a/src/mailman/__init__.py b/src/mailman/__init__.py index 4b166476d..e97ad4c56 100644 --- a/src/mailman/__init__.py +++ b/src/mailman/__init__.py @@ -17,14 +17,13 @@ """The `mailman` package.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ ] -import os import sys diff --git a/src/mailman/app/commands.py b/src/mailman/app/commands.py index 8dbca8d4b..a0f717138 100644 --- a/src/mailman/app/commands.py +++ b/src/mailman/app/commands.py @@ -17,7 +17,7 @@ """Initialize the email commands.""" -from __future__ import unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/app/docs/bounces.rst b/src/mailman/app/docs/bounces.rst index 31d2e51d2..127a05ef6 100644 --- a/src/mailman/app/docs/bounces.rst +++ b/src/mailman/app/docs/bounces.rst @@ -34,7 +34,7 @@ to the original message author. >>> items = get_queue_messages('virgin') >>> len(items) 1 - >>> print items[0].msg.as_string() + >>> print(items[0].msg.as_string()) Subject: Something important From: text-owner@example.com To: aperson@example.com @@ -72,7 +72,7 @@ passed in as an instance of a ``RejectMessage`` exception. >>> items = get_queue_messages('virgin') >>> len(items) 1 - >>> print items[0].msg.as_string() + >>> print(items[0].msg.as_string()) Subject: Something important From: text-owner@example.com To: aperson@example.com diff --git a/src/mailman/app/docs/chains.rst b/src/mailman/app/docs/chains.rst index 7975d23fe..1feecbd68 100644 --- a/src/mailman/app/docs/chains.rst +++ b/src/mailman/app/docs/chains.rst @@ -17,9 +17,9 @@ The `discard` chain simply throws the message away. :: >>> chain = config.chains['discard'] - >>> print chain.name + >>> print(chain.name) discard - >>> print chain.description + >>> print(chain.description) Discard a message and stop processing. >>> mlist = create_list('test@example.com') @@ -33,8 +33,8 @@ The `discard` chain simply throws the message away. ... """) >>> def print_msgid(event): - ... print '{0}: {1}'.format( - ... event.chain.name.upper(), event.msg.get('message-id', 'n/a')) + ... print('{0}: {1}'.format( + ... event.chain.name.upper(), event.msg.get('message-id', 'n/a'))) >>> from mailman.core.chains import process >>> from mailman.testing.helpers import event_subscribers @@ -52,9 +52,9 @@ this action. :: >>> chain = config.chains['reject'] - >>> print chain.name + >>> print(chain.name) reject - >>> print chain.description + >>> print(chain.description) Reject/bounce a message and stop processing. >>> with event_subscribers(print_msgid): @@ -67,7 +67,7 @@ The bounce message is now sitting in the `virgin` queue. >>> qfiles = get_queue_messages('virgin') >>> len(qfiles) 1 - >>> print qfiles[0].msg.as_string() + >>> print(qfiles[0].msg.as_string()) Subject: My first post From: test-owner@example.com To: aperson@example.com @@ -95,9 +95,9 @@ and depending on the list's settings, sends a notification to both the original sender and the list moderators. :: >>> chain = config.chains['hold'] - >>> print chain.name + >>> print(chain.name) hold - >>> print chain.description + >>> print(chain.description) Hold a message and stop processing. >>> with event_subscribers(print_msgid): @@ -120,7 +120,7 @@ is addressed to the original sender. This one is addressed to the list moderators. - >>> print messages[0].as_string() + >>> print(messages[0].as_string()) Subject: test@example.com post from aperson@example.com requires approval From: test-owner@example.com To: test-owner@example.com @@ -173,7 +173,7 @@ This one is addressed to the list moderators. This message is addressed to the sender of the message. - >>> print messages[1].as_string() + >>> print(messages[1].as_string()) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit @@ -235,7 +235,7 @@ The message itself is held in the message store. >>> msg = getUtility(IMessageStore).get_message_by_id( ... rdata['_mod_message_id']) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com To: test@example.com Subject: My first post @@ -254,9 +254,9 @@ processed and sent on to the list membership. :: >>> chain = config.chains['accept'] - >>> print chain.name + >>> print(chain.name) accept - >>> print chain.description + >>> print(chain.description) Accept a message. >>> with event_subscribers(print_msgid): @@ -266,7 +266,7 @@ processed and sent on to the list membership. >>> qfiles = get_queue_messages('pipeline') >>> len(qfiles) 1 - >>> print qfiles[0].msg.as_string() + >>> print(qfiles[0].msg.as_string()) From: aperson@example.com To: test@example.com Subject: My first post @@ -290,9 +290,9 @@ other input chain is defined for a mailing list. It runs through the default rules. >>> chain = config.chains['default-posting-chain'] - >>> print chain.name + >>> print(chain.name) default-posting-chain - >>> print chain.description + >>> print(chain.description) The built-in moderation chain. Once the sender is a member of the mailing list, the previously created @@ -310,7 +310,7 @@ This message will end up in the `pipeline` queue. >>> qfiles = get_queue_messages('pipeline') >>> len(qfiles) 1 - >>> print qfiles[0].msg.as_string() + >>> print(qfiles[0].msg.as_string()) From: aperson@example.com To: test@example.com Subject: My first post diff --git a/src/mailman/app/docs/hooks.rst b/src/mailman/app/docs/hooks.rst index a29c7ee10..ca33f55fe 100644 --- a/src/mailman/app/docs/hooks.rst +++ b/src/mailman/app/docs/hooks.rst @@ -14,7 +14,7 @@ Hooks name an importable callable so it must be accessible on ``sys.path``. >>> hook_path = os.path.join(config_directory, 'hooks.py') >>> with open(hook_path, 'w') as fp: - ... print >> fp, """\ + ... print("""\ ... counter = 1 ... def pre_hook(): ... global counter @@ -25,7 +25,7 @@ Hooks name an importable callable so it must be accessible on ``sys.path``. ... global counter ... print 'post-hook:', counter ... counter += 1 - ... """ + ... """, file=fp) >>> fp.close() @@ -36,13 +36,13 @@ We can set the pre-hook in the configuration file. >>> config_path = os.path.join(config_directory, 'hooks.cfg') >>> with open(config_path, 'w') as fp: - ... print >> fp, """\ + ... print("""\ ... [meta] ... extends: test.cfg ... ... [mailman] ... pre_hook: hooks.pre_hook - ... """ + ... """, file=fp) The hooks are run in the second and third steps of initialization. However, we can't run those initialization steps in process, so call a command line @@ -61,7 +61,7 @@ script that will produce no output to force the hooks to run. ... stdout=subprocess.PIPE, stderr=subprocess.PIPE) ... stdout, stderr = proc.communicate() ... assert proc.returncode == 0, stderr - ... print stdout + ... print(stdout) >>> call() pre-hook: 1 @@ -77,13 +77,13 @@ We can set the post-hook in the configuration file. :: >>> with open(config_path, 'w') as fp: - ... print >> fp, """\ + ... print("""\ ... [meta] ... extends: test.cfg ... ... [mailman] ... post_hook: hooks.post_hook - ... """ + ... """, file=fp) >>> call() post-hook: 1 @@ -99,14 +99,14 @@ We can set the pre- and post-hooks in the configuration file. :: >>> with open(config_path, 'w') as fp: - ... print >> fp, """\ + ... print("""\ ... [meta] ... extends: test.cfg ... ... [mailman] ... pre_hook: hooks.pre_hook ... post_hook: hooks.post_hook - ... """ + ... """, file=fp) >>> call() pre-hook: 1 diff --git a/src/mailman/app/docs/lifecycle.rst b/src/mailman/app/docs/lifecycle.rst index ee7185373..f059806af 100644 --- a/src/mailman/app/docs/lifecycle.rst +++ b/src/mailman/app/docs/lifecycle.rst @@ -52,7 +52,7 @@ However, all addresses are linked to users. >>> user_manager = getUtility(IUserManager) >>> for address in owners: ... user = user_manager.get_user(address) - ... print int(user.user_id.int), list(user.addresses)[0] + ... print(int(user.user_id.int), list(user.addresses)[0]) 1 aperson@example.com 2 bperson@example.com 3 cperson@example.com @@ -64,7 +64,7 @@ the system, they won't be created again. >>> bee = create_list('bee@example.com', owners) >>> from operator import attrgetter >>> for user in sorted(bee.owners.users, key=attrgetter('user_id')): - ... print int(user.user_id.int), list(user.addresses)[0] + ... print(int(user.user_id.int), list(user.addresses)[0]) 1 aperson@example.com 2 bperson@example.com 3 cperson@example.com @@ -82,7 +82,7 @@ artifacts. >>> remove_list(bee) >>> from mailman.interfaces.listmanager import IListManager - >>> print getUtility(IListManager).get('bee@example.com') + >>> print(getUtility(IListManager).get('bee@example.com')) None We should now be able to completely recreate the mailing list. diff --git a/src/mailman/app/docs/message.rst b/src/mailman/app/docs/message.rst index 3c3fd8ea8..658bf4e30 100644 --- a/src/mailman/app/docs/message.rst +++ b/src/mailman/app/docs/message.rst @@ -32,7 +32,7 @@ The message will end up in the `virgin` queue. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit @@ -59,7 +59,7 @@ Again, the message will end up in the `virgin` queue but with the original >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg['precedence'] + >>> print(messages[0].msg['precedence']) list Sometimes we want to send the message without a `Precedence:` header such as @@ -74,7 +74,7 @@ Again, the message will end up in the `virgin` queue but without the >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg['precedence'] + >>> print(messages[0].msg['precedence']) None However, if the message already has a `Precedence:` header, setting the @@ -85,5 +85,5 @@ However, if the message already has a `Precedence:` header, setting the >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg['precedence'] + >>> print(messages[0].msg['precedence']) junk diff --git a/src/mailman/app/docs/moderator.rst b/src/mailman/app/docs/moderator.rst index ec48f6e88..ee9df8eb5 100644 --- a/src/mailman/app/docs/moderator.rst +++ b/src/mailman/app/docs/moderator.rst @@ -84,13 +84,13 @@ The most trivial is to simply defer a decision for now. This leaves the message in the requests database. >>> key, data = requests.get_request(1) - >>> print key + >>> print(key) The moderator can also discard the message. >>> handle_message(mlist, 1, Action.discard) - >>> print requests.get_request(1) + >>> print(requests.get_request(1)) None The message can be rejected, which bounces the message back to the original @@ -100,7 +100,7 @@ sender. The message is no longer available in the requests database. - >>> print requests.get_request(2) + >>> print(requests.get_request(2)) None And there is one message in the *virgin* queue - the rejection notice. @@ -109,7 +109,7 @@ And there is one message in the *virgin* queue - the rejection notice. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 ... Subject: Request to mailing list "A Test List" rejected @@ -135,7 +135,7 @@ And there is one message in the *virgin* queue - the rejection notice. The bounce gets sent to the original sender. >>> for recipient in sorted(messages[0].msgdata['recipients']): - ... print recipient + ... print(recipient) bart@example.org Or the message can be approved. @@ -158,7 +158,7 @@ however the message metadata indicates that the message has been approved. >>> messages = get_queue_messages('pipeline') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) From: cris@example.org To: ant@example.com Subject: Something important @@ -195,7 +195,7 @@ a copy to be preserve, which skips deleting the message from the storage. >>> from mailman.interfaces.messages import IMessageStore >>> from zope.component import getUtility >>> message_store = getUtility(IMessageStore) - >>> print message_store.get_message_by_id('')['message-id'] + >>> print(message_store.get_message_by_id('')['message-id']) Orthogonal to preservation, the message can also be forwarded to another @@ -221,14 +221,14 @@ The forwarded message is in the virgin queue, destined for the moderator. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) Subject: Forward of moderated message From: ant-bounces@example.com To: zack@example.com ... >>> for recipient in sorted(messages[0].msgdata['recipients']): - ... print recipient + ... print(recipient) zack@example.com @@ -264,7 +264,7 @@ simply defer a decision for now. The held subscription can also be discarded. >>> handle_subscription(mlist, 2, Action.discard) - >>> print requests.get_request(2) + >>> print(requests.get_request(2)) None Gwen tries to subscribe to the mailing list, but... @@ -283,7 +283,7 @@ Gwen tries to subscribe to the mailing list, but... ...and she receives a rejection notice. - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 ... Subject: Request to mailing list "A Test List" rejected @@ -315,7 +315,7 @@ The moderators accept the subscription request. And now Herb is a member of the mailing list. - >>> print mlist.members.get_member('herb@example.org').address + >>> print(mlist.members.get_member('herb@example.org').address) Herb Person @@ -335,14 +335,14 @@ As with subscription requests, the unsubscription request can be deferred. >>> from mailman.app.moderator import handle_unsubscription >>> handle_unsubscription(mlist, 2, Action.defer) - >>> print mlist.members.get_member('herb@example.org').address + >>> print(mlist.members.get_member('herb@example.org').address) Herb Person The held unsubscription can also be discarded, and the member will remain subscribed. >>> handle_unsubscription(mlist, 2, Action.discard) - >>> print mlist.members.get_member('herb@example.org').address + >>> print(mlist.members.get_member('herb@example.org').address) Herb Person The request can be rejected, in which case a message is sent to the member, @@ -351,7 +351,7 @@ and the person remains a member of the mailing list. >>> hold_unsubscription(mlist, 'herb@example.org') 2 >>> handle_unsubscription(mlist, 2, Action.reject, 'No can do') - >>> print mlist.members.get_member('herb@example.org').address + >>> print(mlist.members.get_member('herb@example.org').address) Herb Person Herb gets a rejection notice. @@ -361,7 +361,7 @@ Herb gets a rejection notice. >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 ... Subject: Request to mailing list "A Test List" rejected @@ -385,7 +385,7 @@ the mailing list. 2 >>> mlist.send_goodbye_message = False >>> handle_unsubscription(mlist, 2, Action.accept) - >>> print mlist.members.get_member('herb@example.org') + >>> print(mlist.members.get_member('herb@example.org')) None @@ -412,7 +412,7 @@ There's now a message in the virgin queue, destined for the list owner. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 ... Subject: New subscription request to A Test List from iris@example.org @@ -434,7 +434,7 @@ Jeff is a member of the mailing list, and chooses to unsubscribe. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 ... Subject: New unsubscription request from A Test List by jeff@example.org @@ -461,7 +461,7 @@ receive a membership change notice. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 ... Subject: A Test List subscription notification @@ -480,7 +480,7 @@ get a notification. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 ... Subject: A Test List unsubscription notification @@ -505,7 +505,7 @@ can get a welcome message. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 ... Subject: Welcome to the "A Test List" mailing list @@ -529,7 +529,7 @@ goodbye message. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 ... Subject: You have been unsubscribed from the A Test List mailing list diff --git a/src/mailman/app/docs/pipelines.rst b/src/mailman/app/docs/pipelines.rst index 96d9d232a..5aaf7cf62 100644 --- a/src/mailman/app/docs/pipelines.rst +++ b/src/mailman/app/docs/pipelines.rst @@ -9,7 +9,7 @@ handlers, each of which is applied in turn. Unlike rules and chains, there is no way to stop a pipeline from processing the message once it's started. >>> mlist = create_list('test@example.com') - >>> print mlist.posting_pipeline + >>> print(mlist.posting_pipeline) default-posting-pipeline >>> from mailman.core.pipelines import process @@ -34,7 +34,7 @@ Messages hit the pipeline after they've been accepted for posting. The message has been modified with additional headers, footer decorations, etc. - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com To: test@example.com Message-ID: @@ -73,7 +73,7 @@ processing queues. >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) From: aperson@example.com To: test@example.com Message-ID: @@ -110,7 +110,7 @@ delivered to end recipients. >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) From: aperson@example.com To: test@example.com Message-ID: @@ -141,7 +141,7 @@ There's now one message in the digest mailbox, getting ready to be sent. >>> sum(1 for mboxmsg in digest) 1 - >>> print list(digest)[0].as_string() + >>> print(list(digest)[0].as_string()) From: aperson@example.com To: test@example.com Message-ID: diff --git a/src/mailman/app/docs/subscriptions.rst b/src/mailman/app/docs/subscriptions.rst index dd8298cb3..8c3d8b28d 100644 --- a/src/mailman/app/docs/subscriptions.rst +++ b/src/mailman/app/docs/subscriptions.rst @@ -18,7 +18,7 @@ membership role. At first, there are no memberships. >>> sum(1 for member in service) 0 >>> from uuid import UUID - >>> print service.get_member(UUID(int=801)) + >>> print(service.get_member(UUID(int=801))) None @@ -60,7 +60,7 @@ And all the subscribed members can now be displayed. as MemberRole.member>] >>> sum(1 for member in service) 3 - >>> print service.get_member(UUID(int=3)) + >>> print(service.get_member(UUID(int=3))) on test@example.com as MemberRole.owner> New members can also be added by providing an existing user id instead of an diff --git a/src/mailman/app/docs/system.rst b/src/mailman/app/docs/system.rst index 844db9ee6..a7d2285d3 100644 --- a/src/mailman/app/docs/system.rst +++ b/src/mailman/app/docs/system.rst @@ -15,7 +15,7 @@ implements the ``ISystem`` interface. The Mailman version is also available via the ``system`` object. - >>> print system.mailman_version + >>> print(system.mailman_version) GNU Mailman ... The Python version running underneath is also available via the ``system`` diff --git a/src/mailman/app/domain.py b/src/mailman/app/domain.py index ecaa3c230..7ad976699 100644 --- a/src/mailman/app/domain.py +++ b/src/mailman/app/domain.py @@ -17,7 +17,7 @@ """Application level domain support.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/app/events.py b/src/mailman/app/events.py index 3730d5aad..16817c202 100644 --- a/src/mailman/app/events.py +++ b/src/mailman/app/events.py @@ -17,7 +17,7 @@ """Global events.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/app/lifecycle.py b/src/mailman/app/lifecycle.py index 676953ebe..8110fe69d 100644 --- a/src/mailman/app/lifecycle.py +++ b/src/mailman/app/lifecycle.py @@ -17,7 +17,7 @@ """Application level list creation.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/app/moderator.py b/src/mailman/app/moderator.py index 046450305..78332b84a 100644 --- a/src/mailman/app/moderator.py +++ b/src/mailman/app/moderator.py @@ -17,7 +17,7 @@ """Application support for moderators.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/app/replybot.py b/src/mailman/app/replybot.py index 30d547d8a..4ade73faf 100644 --- a/src/mailman/app/replybot.py +++ b/src/mailman/app/replybot.py @@ -21,7 +21,7 @@ # mailing list. The reply governor should really apply site-wide per # recipient (I think). -from __future__ import unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/archiving/docs/common.rst b/src/mailman/archiving/docs/common.rst index 86488b26e..e44247bbd 100644 --- a/src/mailman/archiving/docs/common.rst +++ b/src/mailman/archiving/docs/common.rst @@ -27,9 +27,9 @@ interoperate. >>> archivers = {} >>> from operator import attrgetter >>> for archiver in sorted(config.archivers, key=attrgetter('name')): - ... print archiver.name - ... print ' ', archiver.list_url(mlist) - ... print ' ', archiver.permalink(mlist, msg) + ... print(archiver.name) + ... print(' ', archiver.list_url(mlist)) + ... print(' ', archiver.permalink(mlist, msg)) ... archivers[archiver.name] = archiver mail-archive http://go.mail-archive.dev/test%40example.com @@ -63,9 +63,9 @@ for free. Mailman comes with a plugin for this archiver; by enabling it messages to public lists will get sent there automatically. >>> archiver = archivers['mail-archive'] - >>> print archiver.list_url(mlist) + >>> print(archiver.list_url(mlist)) http://go.mail-archive.dev/test%40example.com - >>> print archiver.permalink(mlist, msg) + >>> print(archiver.permalink(mlist, msg)) http://go.mail-archive.dev/RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE To archive the message, the archiver actually mails the message to a special @@ -86,7 +86,7 @@ address at The Mail Archive. The message gets no header or footer decoration. >>> len(messages) 1 - >>> print messages[0].as_string() + >>> print(messages[0].as_string()) From: aperson@example.org To: test@example.com Subject: An archived message @@ -104,9 +104,9 @@ However, if the mailing list is not public, the message will never be archived at this service. >>> mlist.archive_policy = ArchivePolicy.private - >>> print archiver.list_url(mlist) + >>> print(archiver.list_url(mlist)) None - >>> print archiver.permalink(mlist, msg) + >>> print(archiver.permalink(mlist, msg)) None >>> archiver.archive_message(mlist, msg) >>> list(smtpd.messages) @@ -121,21 +121,21 @@ Additionally, this archiver can handle malformed ``Message-IDs``. >>> del msg['x-message-id-hash'] >>> msg['Message-ID'] = '12345>' >>> add_message_hash(msg) - >>> print archiver.permalink(mlist, msg) + >>> print(archiver.permalink(mlist, msg)) http://go.mail-archive.dev/YJIGBYRWZFG5LZEBQ7NR25B5HBR2BVD6 >>> del msg['message-id'] >>> del msg['x-message-id-hash'] >>> msg['Message-ID'] = '<12345' >>> add_message_hash(msg) - >>> print archiver.permalink(mlist, msg) + >>> print(archiver.permalink(mlist, msg)) http://go.mail-archive.dev/XUFFJNJ2P2WC4NDPQRZFDJMV24POP64B >>> del msg['message-id'] >>> del msg['x-message-id-hash'] >>> msg['Message-ID'] = '12345' >>> add_message_hash(msg) - >>> print archiver.permalink(mlist, msg) + >>> print(archiver.permalink(mlist, msg)) http://go.mail-archive.dev/RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE >>> del msg['message-id'] @@ -143,7 +143,7 @@ Additionally, this archiver can handle malformed ``Message-IDs``. >>> add_message_hash(msg) >>> msg['Message-ID'] = ' 12345 ' >>> add_message_hash(msg) - >>> print archiver.permalink(mlist, msg) + >>> print(archiver.permalink(mlist, msg)) http://go.mail-archive.dev/RSZCG7IGPHFIRW3EMTVMMDNJMNCVCOLE @@ -153,7 +153,7 @@ MHonArc A MHonArc_ archiver is also available. >>> archiver = archivers['mhonarc'] - >>> print archiver.name + >>> print(archiver.name) mhonarc Messages sent to a local MHonArc instance are added to its archive via a @@ -162,7 +162,7 @@ subprocess call. >>> from mailman.testing.helpers import LogFileMark >>> mark = LogFileMark('mailman.archiver') >>> archiver.archive_message(mlist, msg) - >>> print 'LOG:', mark.readline() + >>> print('LOG:', mark.readline()) LOG: ... /usr/bin/mhonarc -add -dbfile .../test@example.com.mbox/mhonarc.db diff --git a/src/mailman/bin/bumpdigests.py b/src/mailman/bin/bumpdigests.py index 25fbe7739..020eb59ce 100644 --- a/src/mailman/bin/bumpdigests.py +++ b/src/mailman/bin/bumpdigests.py @@ -51,7 +51,7 @@ def main(): listnames = set(args or config.list_manager.names) if not listnames: - print _('Nothing to do.') + print(_('Nothing to do.')) sys.exit(0) for listname in listnames: @@ -60,7 +60,7 @@ def main(): mlist = MailList.MailList(listname) except errors.MMListError: parser.print_help() - print >> sys.stderr, _('No such list: $listname') + print(_('No such list: $listname'), file=sys.stderr) sys.exit(1) try: mlist.bump_digest_volume() diff --git a/src/mailman/bin/checkdbs.py b/src/mailman/bin/checkdbs.py index 3a5ad736e..7b0c6c6f2 100644 --- a/src/mailman/bin/checkdbs.py +++ b/src/mailman/bin/checkdbs.py @@ -51,7 +51,7 @@ Check for pending admin requests and mail the list owners if necessary.""")) opts, args = parser.parse_args() if args: parser.print_help() - print >> sys.stderr, _('Unexpected arguments') + print(_('Unexpected arguments'), file=sys.stderr) sys.exit(1) return opts, args, parser diff --git a/src/mailman/bin/docs/master.rst b/src/mailman/bin/docs/master.rst index c4410bf16..3d10b69ac 100644 --- a/src/mailman/bin/docs/master.rst +++ b/src/mailman/bin/docs/master.rst @@ -44,7 +44,7 @@ None of the children are running now. >>> for pid in master.runner_pids: ... try: ... os.kill(pid, 0) - ... print 'Process did not exit:', pid + ... print('Process did not exit:', pid) ... except OSError as error: ... if error.errno == errno.ESRCH: ... # The child process exited. diff --git a/src/mailman/bin/master.py b/src/mailman/bin/master.py index 29d5401f6..2b3ec87c4 100644 --- a/src/mailman/bin/master.py +++ b/src/mailman/bin/master.py @@ -17,7 +17,7 @@ """Master subprocess watcher.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ @@ -518,7 +518,7 @@ def main(): lock = acquire_lock(options.options.force) try: with open(config.PID_FILE, 'w') as fp: - print >> fp, os.getpid() + print(os.getpid(), file=fp) loop = Loop(lock, options.options.restartable, options.options.config) loop.install_signal_handlers() try: diff --git a/src/mailman/bin/onebounce.py b/src/mailman/bin/onebounce.py index 32f56cb9d..1c23fc42a 100644 --- a/src/mailman/bin/onebounce.py +++ b/src/mailman/bin/onebounce.py @@ -18,7 +18,7 @@ """Test bounce detection on message files.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ @@ -70,5 +70,5 @@ def main(): options.initialize() if options.options.list: - print 'list of available bounce modules.' + print('list of available bounce modules.') sys.exit(0) diff --git a/src/mailman/bin/runner.py b/src/mailman/bin/runner.py index c5040e3e3..76da0364f 100644 --- a/src/mailman/bin/runner.py +++ b/src/mailman/bin/runner.py @@ -17,7 +17,7 @@ """The runner process.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ @@ -82,7 +82,8 @@ def make_runner(name, slice, range, once=False): if os.environ.get('MAILMAN_UNDER_MASTER_CONTROL') is not None: # Exit with SIGTERM exit code so the master watcher won't try to # restart us. - print >> sys.stderr, _('Cannot import runner module: $class_path') + print(_('Cannot import runner module: $class_path'), + file=sys.stderr) traceback.print_exc() sys.exit(signal.SIGTERM) else: @@ -190,7 +191,7 @@ def main(): for shortname in sorted(descriptions): classname = descriptions[shortname] name = (' ' * (longest - len(shortname))) + shortname - print _('$name runs $classname') + print(_('$name runs $classname')) sys.exit(0) runner = make_runner(*args.runner, once=args.once) diff --git a/src/mailman/bin/tests/test_master.py b/src/mailman/bin/tests/test_master.py index 6d859b44b..924fbeafd 100644 --- a/src/mailman/bin/tests/test_master.py +++ b/src/mailman/bin/tests/test_master.py @@ -17,7 +17,7 @@ """Test master watcher utilities.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/chains/accept.py b/src/mailman/chains/accept.py index 97b6019a8..f5dd5a73d 100644 --- a/src/mailman/chains/accept.py +++ b/src/mailman/chains/accept.py @@ -17,7 +17,7 @@ """The terminal 'accept' chain.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/chains/discard.py b/src/mailman/chains/discard.py index 067eaa6a8..001b243ac 100644 --- a/src/mailman/chains/discard.py +++ b/src/mailman/chains/discard.py @@ -17,7 +17,7 @@ """The terminal 'discard' chain.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/chains/docs/moderation.rst b/src/mailman/chains/docs/moderation.rst index 1e968ee68..1fe7e40cb 100644 --- a/src/mailman/chains/docs/moderation.rst +++ b/src/mailman/chains/docs/moderation.rst @@ -38,7 +38,7 @@ set to moderate new member postings. ... DeliveryMode.regular, 'en') >>> member on test@example.com as MemberRole.member> - >>> print member.moderation_action + >>> print(member.moderation_action) Action.defer In order to find out whether the message is held or accepted, we can subscribe @@ -48,15 +48,15 @@ to Zope events that are triggered on each case. >>> from mailman.interfaces.chain import ChainEvent >>> def on_chain(event): ... if isinstance(event, ChainEvent): - ... print event - ... print event.chain - ... print 'Subject:', event.msg['subject'] - ... print 'Hits:' + ... print(event) + ... print(event.chain) + ... print('Subject:', event.msg['subject']) + ... print('Hits:') ... for hit in event.msgdata.get('rule_hits', []): - ... print ' ', hit - ... print 'Misses:' + ... print(' ', hit) + ... print('Misses:') ... for miss in event.msgdata.get('rule_misses', []): - ... print ' ', miss + ... print(' ', miss) Anne's post to the mailing list runs through the incoming runner's default built-in chain. No rules hit and so the message is accepted. @@ -218,5 +218,5 @@ moderator approval. >>> nonmember = mlist.nonmembers.get_member('bart@example.com') >>> nonmember - >>> print nonmember.moderation_action + >>> print(nonmember.moderation_action) Action.hold diff --git a/src/mailman/chains/reject.py b/src/mailman/chains/reject.py index c229761a6..e24cedb85 100644 --- a/src/mailman/chains/reject.py +++ b/src/mailman/chains/reject.py @@ -17,7 +17,7 @@ """The terminal 'reject' chain.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/chains/tests/test_hold.py b/src/mailman/chains/tests/test_hold.py index a261a8860..a1fddd558 100644 --- a/src/mailman/chains/tests/test_hold.py +++ b/src/mailman/chains/tests/test_hold.py @@ -17,10 +17,11 @@ """Additional tests for the hold chain.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ + 'TestAutorespond', ] diff --git a/src/mailman/commands/docs/aliases.rst b/src/mailman/commands/docs/aliases.rst index 713064b0f..528a77770 100644 --- a/src/mailman/commands/docs/aliases.rst +++ b/src/mailman/commands/docs/aliases.rst @@ -44,14 +44,14 @@ For Postfix, there are two files in the output directory. >>> files = sorted(os.listdir(output_directory)) >>> for file in files: - ... print file + ... print(file) postfix_domains postfix_lmtp The transport map file contains all the aliases for the mailing list. >>> with open(os.path.join(output_directory, 'postfix_lmtp')) as fp: - ... print fp.read() + ... print(fp.read()) # AUTOMATICALLY GENERATED BY MAILMAN ON ... ... test@example.com lmtp:[lmtp.example.com]:24 @@ -68,7 +68,7 @@ The transport map file contains all the aliases for the mailing list. The relay domains file contains a list of all the domains. >>> with open(os.path.join(output_directory, 'postfix_domains')) as fp: - ... print fp.read() + ... print(fp.read()) # AUTOMATICALLY GENERATED BY MAILMAN ON ... ... example.com example.com diff --git a/src/mailman/commands/docs/control.rst b/src/mailman/commands/docs/control.rst index 184c5873b..b268b50a4 100644 --- a/src/mailman/commands/docs/control.rst +++ b/src/mailman/commands/docs/control.rst @@ -70,7 +70,7 @@ stops all the child processes too. ... except OSError as error: ... if error.errno == errno.ESRCH: ... # The process has exited. - ... print 'Master process went bye bye' + ... print('Master process went bye bye') ... return ... else: ... raise diff --git a/src/mailman/commands/docs/create.rst b/src/mailman/commands/docs/create.rst index 6ef72e573..bec4ea8b6 100644 --- a/src/mailman/commands/docs/create.rst +++ b/src/mailman/commands/docs/create.rst @@ -19,7 +19,7 @@ You cannot create a mailing list in an unknown domain. >>> class FakeParser: ... def error(self, message): - ... print message + ... print(message) >>> command.parser = FakeParser() >>> FakeArgs.listname = ['test@example.xx'] @@ -134,7 +134,7 @@ The language must be known to Mailman. Created mailing list: test3@example.com >>> mlist = list_manager.get('test3@example.com') - >>> print mlist.preferred_language + >>> print(mlist.preferred_language) >>> FakeArgs.language = None @@ -158,7 +158,7 @@ The notification message is in the virgin queue. 1 >>> for message in messages: - ... print message.msg.as_string() + ... print(message.msg.as_string()) MIME-Version: 1.0 ... Subject: Your new mailing list: test6@example.com diff --git a/src/mailman/commands/docs/echo.rst b/src/mailman/commands/docs/echo.rst index db5161e1e..32399ebfc 100644 --- a/src/mailman/commands/docs/echo.rst +++ b/src/mailman/commands/docs/echo.rst @@ -6,11 +6,11 @@ The mail command 'echo' simply replies with the original command and arguments to the sender. >>> command = config.commands['echo'] - >>> print command.name + >>> print(command.name) echo - >>> print command.argument_description + >>> print(command.argument_description) [args] - >>> print command.description + >>> print(command.description) Echo back your arguments. The original message is ignored, but the results receive the echoed command. @@ -22,9 +22,9 @@ The original message is ignored, but the results receive the echoed command. >>> results = Results() >>> from mailman.email.message import Message - >>> print command.process(mlist, Message(), {}, ('foo', 'bar'), results) + >>> print(command.process(mlist, Message(), {}, ('foo', 'bar'), results)) ContinueProcessing.yes - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. echo foo bar diff --git a/src/mailman/commands/docs/end.rst b/src/mailman/commands/docs/end.rst index 8cd4b2409..38c268c1c 100644 --- a/src/mailman/commands/docs/end.rst +++ b/src/mailman/commands/docs/end.rst @@ -6,14 +6,14 @@ The mail command processor recognized an 'end' command which tells it to stop processing email messages. >>> command = config.commands['end'] - >>> print command.name + >>> print(command.name) end - >>> print command.description + >>> print(command.description) Stop processing commands. The 'end' command takes no arguments. - >>> print 'DESCRIPTION:', command.argument_description + >>> print('DESCRIPTION:', command.argument_description) DESCRIPTION: The command itself is fairly simple; it just stops command processing, and the @@ -21,17 +21,17 @@ message isn't even looked at. >>> mlist = create_list('test@example.com') >>> from mailman.email.message import Message - >>> print command.process(mlist, Message(), {}, (), None) + >>> print(command.process(mlist, Message(), {}, (), None)) ContinueProcessing.no The 'stop' command is a synonym for 'end'. >>> command = config.commands['stop'] - >>> print command.name + >>> print(command.name) stop - >>> print command.description + >>> print(command.description) An alias for 'end'. - >>> print 'DESCRIPTION:', command.argument_description + >>> print('DESCRIPTION:', command.argument_description) DESCRIPTION: - >>> print command.process(mlist, Message(), {}, (), None) + >>> print(command.process(mlist, Message(), {}, (), None)) ContinueProcessing.no diff --git a/src/mailman/commands/docs/help.rst b/src/mailman/commands/docs/help.rst index a12a4008f..bbd6c8c09 100644 --- a/src/mailman/commands/docs/help.rst +++ b/src/mailman/commands/docs/help.rst @@ -8,11 +8,11 @@ sending the word `help` to a mailing list's -request address. >>> mlist = create_list('test@example.com') >>> from mailman.commands.eml_help import Help >>> help = Help() - >>> print help.name + >>> print(help.name) help - >>> print help.description + >>> print(help.description) Get help about available email commands. - >>> print help.argument_description + >>> print(help.argument_description) [command] With no arguments, `help` provides a list of the available commands and a @@ -23,9 +23,9 @@ short description of each of them. >>> results = Results() >>> from mailman.email.message import Message - >>> print help.process(mlist, Message(), {}, (), results) + >>> print(help.process(mlist, Message(), {}, (), results)) ContinueProcessing.yes - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. confirm - Confirm a subscription request. @@ -42,9 +42,9 @@ short description of each of them. With an argument, you can get more detailed help about a specific command. >>> results = Results() - >>> print help.process(mlist, Message(), {}, ('help',), results) + >>> print(help.process(mlist, Message(), {}, ('help',), results)) ContinueProcessing.yes - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. help [command] @@ -54,9 +54,9 @@ With an argument, you can get more detailed help about a specific command. Some commands have even more detailed help. >>> results = Results() - >>> print help.process(mlist, Message(), {}, ('join',), results) + >>> print(help.process(mlist, Message(), {}, ('join',), results)) ContinueProcessing.yes - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. join [digest=] diff --git a/src/mailman/commands/docs/import.rst b/src/mailman/commands/docs/import.rst index 2ab6f99bd..86a31d6ff 100644 --- a/src/mailman/commands/docs/import.rst +++ b/src/mailman/commands/docs/import.rst @@ -15,7 +15,7 @@ that into an existing mailing list in Mailman 3.0. >>> class FakeParser: ... def error(self, message): - ... print message + ... print(message) >>> command.parser = FakeParser() You must specify the mailing list you are importing into, and it must exist. @@ -48,9 +48,9 @@ import, the mailing list's 'real name' has changed. >>> FakeArgs.pickle_file = [ ... resource_filename('mailman.testing', 'config.pck')] - >>> print mlist.display_name + >>> print(mlist.display_name) Import >>> command.process(FakeArgs) - >>> print mlist.display_name + >>> print(mlist.display_name) Test diff --git a/src/mailman/commands/docs/info.rst b/src/mailman/commands/docs/info.rst index 2a5e691ae..8bc7579e6 100644 --- a/src/mailman/commands/docs/info.rst +++ b/src/mailman/commands/docs/info.rst @@ -31,7 +31,7 @@ By passing in the ``-o/--output`` option, you can print the info to a file. >>> args.output = output_path >>> command.process(args) >>> with open(output_path) as fp: - ... print fp.read() + ... print(fp.read()) GNU Mailman 3... Python ... ... diff --git a/src/mailman/commands/docs/inject.rst b/src/mailman/commands/docs/inject.rst index 5d07e0458..63e7b0366 100644 --- a/src/mailman/commands/docs/inject.rst +++ b/src/mailman/commands/docs/inject.rst @@ -19,7 +19,7 @@ line. >>> class FakeParser: ... def error(self, message): - ... print message + ... print(message) >>> command.parser = FakeParser() It's easy to find out which queues are available. @@ -48,14 +48,14 @@ Usually, the text of the message to inject is in a file. >>> import os, tempfile >>> fd, filename = tempfile.mkstemp() >>> with os.fdopen(fd, 'w') as fp: - ... print >> fp, """\ + ... print("""\ ... From: aperson@example.com ... To: test@example.com ... Subject: testing ... Message-ID: ... ... This is a test message. - ... """ + ... """, file=fp) However, the mailing list name is always required. @@ -81,7 +81,7 @@ By default, the incoming queue is used. >>> items = get_queue_messages('in') >>> len(items) 1 - >>> print items[0].msg.as_string() + >>> print(items[0].msg.as_string()) From: aperson@example.com To: test@example.com Subject: testing @@ -109,7 +109,7 @@ But a different queue can be specified on the command line. >>> items = get_queue_messages('virgin') >>> len(items) 1 - >>> print items[0].msg.as_string() + >>> print(items[0].msg.as_string()) From: aperson@example.com To: test@example.com Subject: testing @@ -154,7 +154,7 @@ The message text can also be provided on standard input. >>> items = get_queue_messages('in') >>> len(items) 1 - >>> print items[0].msg.as_string() + >>> print(items[0].msg.as_string()) From: bperson@example.com To: test@example.com Subject: another test diff --git a/src/mailman/commands/docs/members.rst b/src/mailman/commands/docs/members.rst index 18a916781..7b99e92f9 100644 --- a/src/mailman/commands/docs/members.rst +++ b/src/mailman/commands/docs/members.rst @@ -70,7 +70,7 @@ You can also output this list to a file. >>> os.close(fd) >>> command.process(args) >>> with open(args.output_filename) as fp: - ... print fp.read() + ... print(fp.read()) Anne Person Anne Person Bart Person @@ -213,7 +213,7 @@ need a file containing email addresses and full names that can be parsed by ... 'Bart Person ', ... 'cperson@example.com (Cate Person)', ... ): - ... print >> fp, address + ... print(address, file=fp) >>> args.input_filename = path >>> args.listname = [mlist2.fqdn_listname] @@ -236,7 +236,7 @@ taken from standard input. ... 'Elly Person ', ... 'fperson@example.com (Fred Person)', ... ): - ... print >> fp, address + ... print(address, file=fp) >>> fp.seek(0) >>> import sys >>> sys.stdin = fp @@ -263,7 +263,7 @@ Blank lines and lines that begin with '#' are ignored. ... '', ... 'iperson@example.com', ... ): - ... print >> fp, address + ... print(address, file=fp) >>> args.input_filename = path >>> command.process(args) @@ -286,7 +286,7 @@ printed. ... 'aperson@example.com', ... 'jperson@example.com', ... ): - ... print >> fp, address + ... print(address, file=fp) >>> command.process(args) Already subscribed (skipping): gperson@example.com diff --git a/src/mailman/commands/docs/membership.rst b/src/mailman/commands/docs/membership.rst index 3faccfe6a..aa3ab97e6 100644 --- a/src/mailman/commands/docs/membership.rst +++ b/src/mailman/commands/docs/membership.rst @@ -16,16 +16,16 @@ The mail command ``join`` subscribes an email address to the mailing list. >>> from mailman.commands.eml_membership import Join >>> from mailman.utilities.string import wrap >>> join = Join() - >>> print join.name + >>> print(join.name) join - >>> print wrap(join.description) + >>> print(wrap(join.description)) You will be asked to confirm your subscription request and you may be issued a provisional password. By using the 'digest' option, you can specify whether you want digest delivery or not. If not specified, the mailing list's default delivery mode will be used. - >>> print join.argument_description + >>> print(join.argument_description) [digest=] @@ -43,9 +43,9 @@ If that's missing though, then an error is returned. >>> results = Results() >>> from mailman.email.message import Message - >>> print join.process(mlist, Message(), {}, (), results) + >>> print(join.process(mlist, Message(), {}, (), results)) ContinueProcessing.no - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. join: No valid address found to subscribe @@ -55,12 +55,12 @@ The ``subscribe`` command is an alias. >>> from mailman.commands.eml_membership import Subscribe >>> subscribe = Subscribe() - >>> print subscribe.name + >>> print(subscribe.name) subscribe >>> results = Results() - >>> print subscribe.process(mlist, Message(), {}, (), results) + >>> print(subscribe.process(mlist, Message(), {}, (), results)) ContinueProcessing.no - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. subscribe: No valid address found to subscribe @@ -77,9 +77,9 @@ When the message has a From field, that address will be subscribed. ... ... """) >>> results = Results() - >>> print join.process(mlist, msg, {}, (), results) + >>> print(join.process(mlist, msg, {}, (), results)) ContinueProcessing.yes - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. Confirmation email sent to Anne Person @@ -91,7 +91,7 @@ first. >>> from mailman.interfaces.usermanager import IUserManager >>> from zope.component import getUtility >>> user_manager = getUtility(IUserManager) - >>> print user_manager.get_user('anne@example.com') + >>> print(user_manager.get_user('anne@example.com')) None Mailman has sent her the confirmation message. @@ -100,7 +100,7 @@ Mailman has sent her the confirmation message. >>> items = get_queue_messages('virgin') >>> len(items) 1 - >>> print items[0].msg.as_string() + >>> print(items[0].msg.as_string()) MIME-Version: 1.0 ... Subject: confirm ... @@ -148,16 +148,16 @@ list. ... """.format(token=token)) >>> results = Results() - >>> print confirm.process(mlist, msg, {}, (token,), results) + >>> print(confirm.process(mlist, msg, {}, (token,), results)) ContinueProcessing.yes - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. Confirmed >>> user = user_manager.get_user('anne@example.com') - >>> print user.display_name + >>> print(user.display_name) Anne Person >>> list(user.addresses) [ [verified] at ...>] @@ -177,17 +177,17 @@ Joining a second list ... From: Anne Person ... ... """) - >>> print join.process(mlist_2, msg, {}, (), Results()) + >>> print(join.process(mlist_2, msg, {}, (), Results())) ContinueProcessing.yes Anne of course, is still registered. - >>> print user_manager.get_user('anne@example.com') + >>> print(user_manager.get_user('anne@example.com')) But she is not a member of the mailing list. - >>> print mlist_2.members.get_member('anne@example.com') + >>> print(mlist_2.members.get_member('anne@example.com')) None One Anne confirms this subscription, she becomes a member of the mailing @@ -206,15 +206,15 @@ list. ... """.format(token=token)) >>> results = Results() - >>> print confirm.process(mlist_2, msg, {}, (token,), results) + >>> print(confirm.process(mlist_2, msg, {}, (token,), results)) ContinueProcessing.yes - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. Confirmed - >>> print mlist_2.members.get_member('anne@example.com') + >>> print(mlist_2.members.get_member('anne@example.com')) on baker@example.com as MemberRole.member> @@ -227,9 +227,9 @@ list. ``unsubscribe`` is an alias for ``leave``. >>> from mailman.commands.eml_membership import Leave >>> leave = Leave() - >>> print leave.name + >>> print(leave.name) leave - >>> print leave.description + >>> print(leave.description) Leave this mailing list. You may be asked to confirm your request. @@ -239,9 +239,9 @@ to leave it. She sends a message to the ``-leave`` address for the list and is sent a confirmation message for her request. >>> results = Results() - >>> print leave.process(mlist_2, msg, {}, (), results) + >>> print(leave.process(mlist_2, msg, {}, (), results)) ContinueProcessing.yes - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. Anne Person left baker@example.com @@ -249,7 +249,7 @@ is sent a confirmation message for her request. Anne is no longer a member of the mailing list. - >>> print mlist_2.members.get_member('anne@example.com') + >>> print(mlist_2.members.get_member('anne@example.com')) None Anne does not need to leave a mailing list with the same email address she's @@ -261,7 +261,7 @@ will do. >>> address = anne.register('anne.person@example.org') >>> results = Results() - >>> print mlist.members.get_member('anne@example.com') + >>> print(mlist.members.get_member('anne@example.com')) on alpha@example.com as MemberRole.member> @@ -275,16 +275,16 @@ Since Anne's alternative address has not yet been verified, it can't be used to unsubscribe Anne from the alpha mailing list. :: - >>> print leave.process(mlist, msg, {}, (), results) + >>> print(leave.process(mlist, msg, {}, (), results)) ContinueProcessing.no - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. Invalid or unverified email address: anne.person@example.org - >>> print mlist.members.get_member('anne@example.com') + >>> print(mlist.members.get_member('anne@example.com')) on alpha@example.com as MemberRole.member> @@ -296,16 +296,16 @@ unsubscribe her from the list. >>> address.verified_on = now() >>> results = Results() - >>> print leave.process(mlist, msg, {}, (), results) + >>> print(leave.process(mlist, msg, {}, (), results)) ContinueProcessing.yes - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. Anne Person left alpha@example.com - >>> print mlist.members.get_member('anne@example.com') + >>> print(mlist.members.get_member('anne@example.com')) None @@ -320,7 +320,7 @@ Bart wants to join the alpha list, so he sends his subscription request. ... ... """) - >>> print join.process(mlist, msg, {}, (), Results()) + >>> print(join.process(mlist, msg, {}, (), Results())) ContinueProcessing.yes There are two messages in the virgin queue, one of which is the confirmation @@ -335,7 +335,7 @@ message. Bart is still not a user. - >>> print user_manager.get_user('bart@example.com') + >>> print(user_manager.get_user('bart@example.com')) None Bart replies to the original message, specifically keeping the Subject header @@ -351,10 +351,10 @@ a user of the system. ... """.format(token=token)) >>> results = Results() - >>> print confirm.process(mlist, msg, {}, (token,), results) + >>> print(confirm.process(mlist, msg, {}, (token,), results)) ContinueProcessing.yes - >>> print unicode(results) + >>> print(unicode(results)) The results of your email command are provided below. Confirmed @@ -362,11 +362,11 @@ a user of the system. Now Bart is a user... - >>> print user_manager.get_user('bart@example.com') + >>> print(user_manager.get_user('bart@example.com')) ...and a member of the mailing list. - >>> print mlist.members.get_member('bart@example.com') + >>> print(mlist.members.get_member('bart@example.com')) on alpha@example.com as MemberRole.member> diff --git a/src/mailman/commands/docs/remove.rst b/src/mailman/commands/docs/remove.rst index 35dc53c5e..c534741f3 100644 --- a/src/mailman/commands/docs/remove.rst +++ b/src/mailman/commands/docs/remove.rst @@ -25,7 +25,7 @@ A system administrator can remove mailing lists by the command line. >>> command.process(args) Removed list: test@example.com - >>> print list_manager.get('test@example.com') + >>> print(list_manager.get('test@example.com')) None You can also remove lists quietly. @@ -37,5 +37,5 @@ You can also remove lists quietly. >>> args.quiet = True >>> command.process(args) - >>> print list_manager.get('test@example.com') + >>> print(list_manager.get('test@example.com')) None diff --git a/src/mailman/commands/docs/unshunt.rst b/src/mailman/commands/docs/unshunt.rst index ce9d70316..93d89f001 100644 --- a/src/mailman/commands/docs/unshunt.rst +++ b/src/mailman/commands/docs/unshunt.rst @@ -45,7 +45,7 @@ queue. >>> items = get_queue_messages('in') >>> len(items) 1 - >>> print items[0].msg.as_string() + >>> print(items[0].msg.as_string()) From: aperson@example.com To: test@example.com Subject: A broken message @@ -121,7 +121,7 @@ The message is automatically re-queued to the bounces queue. >>> len(items) 1 - >>> print items[0].msg.as_string() + >>> print(items[0].msg.as_string()) From: aperson@example.com To: test@example.com Subject: A broken message diff --git a/src/mailman/commands/docs/withlist.rst b/src/mailman/commands/docs/withlist.rst index 99a366c9a..827d246cd 100644 --- a/src/mailman/commands/docs/withlist.rst +++ b/src/mailman/commands/docs/withlist.rst @@ -27,7 +27,7 @@ Because ``withlist`` is so complex, you need to request detailed help. >>> class FakeParser: ... def error(self, message): - ... print message + ... print(message) >>> command.parser = FakeParser() >>> args = FakeArgs() @@ -50,13 +50,13 @@ single argument, the mailing list. >>> sys.path.insert(0, config.VAR_DIR) >>> with open(os.path.join(config.VAR_DIR, 'showme.py'), 'w') as fp: - ... print >> fp, """\ + ... print("""\ ... def showme(mailing_list): ... print "The list's name is", mailing_list.fqdn_listname ... ... def displayname(mailing_list): ... print "The list's display name is", mailing_list.display_name - ... """ + ... """, file=fp) If the name of the function is the same as the module, then you only need to name the function once. diff --git a/src/mailman/commands/tests/test_control.py b/src/mailman/commands/tests/test_control.py index df61edccf..0847d86b1 100644 --- a/src/mailman/commands/tests/test_control.py +++ b/src/mailman/commands/tests/test_control.py @@ -17,10 +17,11 @@ """Test some additional corner cases for starting/stopping.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ + 'TestStart', 'find_master', 'make_config', ] @@ -54,7 +55,7 @@ def make_config(): shutil.copyfile(config.filename, config_file) with open(config_file, 'a') as fp: for runner_config in config.runner_configs: - print >> fp, '[{0}]\nstart:no\n'.format(runner_config.name) + print('[{0}]\nstart:no\n'.format(runner_config.name), file=fp) return config_file diff --git a/src/mailman/commands/tests/test_create.py b/src/mailman/commands/tests/test_create.py index 21ffd9c5b..c2dffb929 100644 --- a/src/mailman/commands/tests/test_create.py +++ b/src/mailman/commands/tests/test_create.py @@ -17,10 +17,11 @@ """Test `bin/mailman create`.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ + 'TestCreate', ] diff --git a/src/mailman/config/__init__.py b/src/mailman/config/__init__.py index cf500bae4..fb240ad76 100644 --- a/src/mailman/config/__init__.py +++ b/src/mailman/config/__init__.py @@ -17,7 +17,7 @@ """Mailman configuration package.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/config/tests/test_configuration.py b/src/mailman/config/tests/test_configuration.py index 3c623c005..ee4827041 100644 --- a/src/mailman/config/tests/test_configuration.py +++ b/src/mailman/config/tests/test_configuration.py @@ -28,6 +28,7 @@ __all__ = [ import os +import mock import tempfile import unittest @@ -121,7 +122,8 @@ layout: nonesuch # Use a fake sys.exit() function that records that it was called, and # that prevents further processing. config = Configuration() - with self.assertRaises(SystemExit) as cm: + # Suppress warning messages in the test output. + with self.assertRaises(SystemExit) as cm, mock.patch('sys.stderr'): config.load(filename) self.assertEqual(cm.exception.args, (1,)) @@ -137,6 +139,7 @@ layout: nonesuch log_dir: $nopath/log_dir """, file=fp) config = Configuration() - with self.assertRaises(SystemExit) as cm: + # Suppress warning messages in the test output. + with self.assertRaises(SystemExit) as cm, mock.patch('sys.stderr'): config.load(filename) self.assertEqual(cm.exception.args, (1,)) diff --git a/src/mailman/core/chains.py b/src/mailman/core/chains.py index ac6f5a50a..df4c199d5 100644 --- a/src/mailman/core/chains.py +++ b/src/mailman/core/chains.py @@ -17,7 +17,7 @@ """Application support for chain processing.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/core/docs/runner.rst b/src/mailman/core/docs/runner.rst index 00781578f..28eab9203 100644 --- a/src/mailman/core/docs/runner.rst +++ b/src/mailman/core/docs/runner.rst @@ -58,7 +58,7 @@ on instance variables. >>> filebase = switchboard.enqueue(msg, listname=mlist.fqdn_listname, ... foo='yes', bar='no') >>> runner.run() - >>> print runner.msg.as_string() + >>> print(runner.msg.as_string()) From: aperson@example.com To: test@example.com diff --git a/src/mailman/core/docs/switchboard.rst b/src/mailman/core/docs/switchboard.rst index 751b1e640..c8d2de079 100644 --- a/src/mailman/core/docs/switchboard.rst +++ b/src/mailman/core/docs/switchboard.rst @@ -17,7 +17,7 @@ Create a switchboard by giving its queue name and directory. >>> queue_directory = os.path.join(config.QUEUE_DIR, 'test') >>> from mailman.core.switchboard import Switchboard >>> switchboard = Switchboard('test', queue_directory) - >>> print switchboard.name + >>> print(switchboard.name) test >>> switchboard.queue_directory == queue_directory True @@ -32,9 +32,9 @@ Here's a helper function for ensuring things work correctly. ... root, ext = os.path.splitext(qfile) ... files[ext] = files.get(ext, 0) + 1 ... if len(files) == 0: - ... print 'empty' + ... print('empty') ... for ext in sorted(files): - ... print '{0}: {1}'.format(ext, files[ext]) + ... print('{0}: {1}'.format(ext, files[ext])) Enqueing and dequeing @@ -50,7 +50,7 @@ dictionary. To read the contents of a queue file, dequeue it. >>> msg, msgdata = switchboard.dequeue(filebase) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com To: _xtest@example.com diff --git a/src/mailman/core/errors.py b/src/mailman/core/errors.py index 56f9948ce..b8f5a1f64 100644 --- a/src/mailman/core/errors.py +++ b/src/mailman/core/errors.py @@ -26,7 +26,7 @@ interfaces. """ -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/core/i18n.py b/src/mailman/core/i18n.py index 80f1a6448..b078a985f 100644 --- a/src/mailman/core/i18n.py +++ b/src/mailman/core/i18n.py @@ -17,7 +17,7 @@ """Internationalization.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/core/logging.py b/src/mailman/core/logging.py index 27799a641..43030436a 100644 --- a/src/mailman/core/logging.py +++ b/src/mailman/core/logging.py @@ -17,7 +17,7 @@ """Logging initialization, using Python's standard logging package.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/core/rules.py b/src/mailman/core/rules.py index d527c62ea..1a2b9f56d 100644 --- a/src/mailman/core/rules.py +++ b/src/mailman/core/rules.py @@ -17,7 +17,7 @@ """Various rule helpers""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/database/docs/migration.rst b/src/mailman/database/docs/migration.rst index de9c41999..fafdfaf26 100644 --- a/src/mailman/database/docs/migration.rst +++ b/src/mailman/database/docs/migration.rst @@ -33,7 +33,7 @@ already applied. 4 >>> versions = sorted(result.version for result in results) >>> for version in versions: - ... print version + ... print(version) 00000000000000 20120407000000 20121015000000 @@ -81,34 +81,34 @@ This migration module just adds a marker to the `version` table. >>> with open(os.path.join(path, '__init__.py'), 'w') as fp: ... pass >>> with open(os.path.join(path, 'mm_20159999000000.py'), 'w') as fp: - ... print >> fp, """ + ... print(""" ... from __future__ import unicode_literals ... from mailman.model.version import Version ... def upgrade(database, store, version, module_path): ... v = Version(component='test', version=version) ... store.add(v) ... database.load_schema(store, version, None, module_path) - ... """ + ... """, file=fp) This will load the new migration, since it hasn't been loaded before. >>> config.db.load_migrations() >>> results = config.db.store.find(Version, component='schema') >>> for result in sorted(result.version for result in results): - ... print result + ... print(result) 00000000000000 20120407000000 20121015000000 20130406000000 20159999000000 >>> test = config.db.store.find(Version, component='test').one() - >>> print test.version + >>> print(test.version) 20159999000000 Migrations will only be loaded once. >>> with open(os.path.join(path, 'mm_20159999000001.py'), 'w') as fp: - ... print >> fp, """ + ... print(""" ... from __future__ import unicode_literals ... from mailman.model.version import Version ... _marker = 801 @@ -120,14 +120,14 @@ Migrations will only be loaded once. ... v = Version(component='test', version=marker) ... store.add(v) ... database.load_schema(store, version, None, module_path) - ... """ + ... """, file=fp) The first time we load this new migration, we'll get the 801 marker. >>> config.db.load_migrations() >>> results = config.db.store.find(Version, component='schema') >>> for result in sorted(result.version for result in results): - ... print result + ... print(result) 00000000000000 20120407000000 20121015000000 @@ -136,7 +136,7 @@ The first time we load this new migration, we'll get the 801 marker. 20159999000001 >>> test = config.db.store.find(Version, component='test') >>> for marker in sorted(marker.version for marker in test): - ... print marker + ... print(marker) 00000000000801 20159999000000 @@ -145,7 +145,7 @@ We do not get an 802 marker because the migration has already been loaded. >>> config.db.load_migrations() >>> results = config.db.store.find(Version, component='schema') >>> for result in sorted(result.version for result in results): - ... print result + ... print(result) 00000000000000 20120407000000 20121015000000 @@ -154,7 +154,7 @@ We do not get an 802 marker because the migration has already been loaded. 20159999000001 >>> test = config.db.store.find(Version, component='test') >>> for marker in sorted(marker.version for marker in test): - ... print marker + ... print(marker) 00000000000801 20159999000000 @@ -181,7 +181,7 @@ You'll notice that the ...04 version is not present. >>> results = config.db.store.find(Version, component='schema') >>> for result in sorted(result.version for result in results): - ... print result + ... print(result) 00000000000000 20120407000000 20121015000000 diff --git a/src/mailman/database/types.py b/src/mailman/database/types.py index eb3a4d357..ba3d92df4 100644 --- a/src/mailman/database/types.py +++ b/src/mailman/database/types.py @@ -18,7 +18,7 @@ """Storm type conversions.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/docs/__init__.py b/src/mailman/docs/__init__.py index b094a1e3d..f588eb14d 100644 --- a/src/mailman/docs/__init__.py +++ b/src/mailman/docs/__init__.py @@ -17,7 +17,7 @@ """General Mailman doc tests.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/email/message.py b/src/mailman/email/message.py index 81185b8d1..f3a44e63c 100644 --- a/src/mailman/email/message.py +++ b/src/mailman/email/message.py @@ -23,7 +23,7 @@ safe pickle deserialization, even if the email package adds additional Message attributes. """ -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/handlers/docs/ack-headers.rst b/src/mailman/handlers/docs/ack-headers.rst index e700e2fd1..0f1b07066 100644 --- a/src/mailman/handlers/docs/ack-headers.rst +++ b/src/mailman/handlers/docs/ack-headers.rst @@ -23,7 +23,7 @@ added. >>> from mailman.handlers.cook_headers import process >>> process(mlist, msg, dict(noack=True)) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com X-Ack: no ... @@ -37,7 +37,7 @@ Any existing ``X-Ack`` header in the original message is removed. ... A message of great import. ... """) >>> process(mlist, msg, dict(noack=True)) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com X-Ack: no ... diff --git a/src/mailman/handlers/docs/acknowledge.rst b/src/mailman/handlers/docs/acknowledge.rst index 2235985ad..e91f94f62 100644 --- a/src/mailman/handlers/docs/acknowledge.rst +++ b/src/mailman/handlers/docs/acknowledge.rst @@ -118,7 +118,7 @@ The receipt will include the original message's subject in the response body, recipients : set([u'aperson@example.com']) reduced_list_headers: True ... - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) ... MIME-Version: 1.0 ... @@ -155,7 +155,7 @@ If there is no subject, then the receipt will use a generic message. recipients : set([u'aperson@example.com']) reduced_list_headers: True ... - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 ... Subject: Test post acknowledgment diff --git a/src/mailman/handlers/docs/archives.rst b/src/mailman/handlers/docs/archives.rst index abaad9f52..b6d06ed99 100644 --- a/src/mailman/handlers/docs/archives.rst +++ b/src/mailman/handlers/docs/archives.rst @@ -100,7 +100,7 @@ But if the value is ``yes``, then the message will be archived. >>> filebase = switchboard.files[0] >>> qmsg, qdata = switchboard.dequeue(filebase) >>> switchboard.finish(filebase) - >>> print qmsg.as_string() + >>> print(qmsg.as_string()) Subject: A sample message X-Archive: Yes @@ -124,7 +124,7 @@ message will get archived. >>> filebase = switchboard.files[0] >>> qmsg, qdata = switchboard.dequeue(filebase) >>> switchboard.finish(filebase) - >>> print qmsg.as_string() + >>> print(qmsg.as_string()) Subject: A sample message A message of great import. diff --git a/src/mailman/handlers/docs/avoid-duplicates.rst b/src/mailman/handlers/docs/avoid-duplicates.rst index 1e46793c2..612634941 100644 --- a/src/mailman/handlers/docs/avoid-duplicates.rst +++ b/src/mailman/handlers/docs/avoid-duplicates.rst @@ -45,7 +45,7 @@ The module short-circuits if there are no recipients. >>> handler.process(mlist, msg, msgdata) >>> msgdata {} - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Subject: A message of great import @@ -72,7 +72,7 @@ or ``Resent-CC``), then they will get a list copy. >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) [u'aperson@example.com', u'bperson@example.com'] - >>> print msg.as_string() + >>> print(msg.as_string()) From: Claire Person Something of great import. @@ -90,7 +90,7 @@ If they're mentioned on the ``CC`` line, they won't get a list copy. >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) [u'bperson@example.com'] - >>> print msg.as_string() + >>> print(msg.as_string()) From: Claire Person CC: aperson@example.com @@ -110,7 +110,7 @@ to ``True`` (the default), then they still get a list copy. >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) [u'aperson@example.com', u'bperson@example.com'] - >>> print msg.as_string() + >>> print(msg.as_string()) From: Claire Person CC: bperson@example.com @@ -129,7 +129,7 @@ Other headers checked for recipients include the ``To``... >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) [u'bperson@example.com'] - >>> print msg.as_string() + >>> print(msg.as_string()) From: Claire Person To: aperson@example.com @@ -148,7 +148,7 @@ Other headers checked for recipients include the ``To``... >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) [u'bperson@example.com'] - >>> print msg.as_string() + >>> print(msg.as_string()) From: Claire Person Resent-To: aperson@example.com @@ -167,7 +167,7 @@ Other headers checked for recipients include the ``To``... >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) [u'bperson@example.com'] - >>> print msg.as_string() + >>> print(msg.as_string()) From: Claire Person Resent-Cc: aperson@example.com diff --git a/src/mailman/handlers/docs/cleanse.rst b/src/mailman/handlers/docs/cleanse.rst index 61dfa8f52..78a157d79 100644 --- a/src/mailman/handlers/docs/cleanse.rst +++ b/src/mailman/handlers/docs/cleanse.rst @@ -30,7 +30,7 @@ must be removed from any posted message. :: >>> handler = config.handlers['cleanse'] >>> handler.process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Subject: A message of great import @@ -56,7 +56,7 @@ though (Some Microsoft product perhaps?). ... How are you doing? ... """) >>> handler.process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: bperson@example.com Reply-To: bperson@example.org Sender: asystem@example.net @@ -91,7 +91,7 @@ Hotmail apparently sets ``X-Originating-Email``. ... How are you doing? ... """) >>> handler.process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) Subject: a message to you From: A Test Mailing List <_xtest@example.com> Reply-To: _xtest@example.com diff --git a/src/mailman/handlers/docs/cook-headers.rst b/src/mailman/handlers/docs/cook-headers.rst index 948628d54..0f4c794d4 100644 --- a/src/mailman/handlers/docs/cook-headers.rst +++ b/src/mailman/handlers/docs/cook-headers.rst @@ -28,7 +28,7 @@ will place the sender in the message metadata for safe keeping. >>> from mailman.handlers.cook_headers import process >>> process(mlist, msg, msgdata) - >>> print msgdata['original_sender'] + >>> print(msgdata['original_sender']) aperson@example.com But if there was no original sender, then the empty string will be saved. @@ -40,7 +40,7 @@ But if there was no original sender, then the empty string will be saved. ... """) >>> msgdata = {} >>> process(mlist, msg, msgdata) - >>> print msgdata['original_sender'] + >>> print(msgdata['original_sender']) @@ -68,7 +68,7 @@ Mailman will also insert an ``X-Mailman-Version`` header... ... A message of great import. ... """) >>> process(mlist, msg, {}) - >>> print msg['x-mailman-version'] + >>> print(msg['x-mailman-version']) 3000 @@ -85,7 +85,7 @@ message. ... A message of great import. ... """) >>> process(mlist, msg, {}) - >>> print msg['precedence'] + >>> print(msg['precedence']) list But Mailman will only add that header if the original message doesn't already @@ -98,7 +98,7 @@ have one of them. ... A message of great import. ... """) >>> process(mlist, msg, {}) - >>> print msg['precedence'] + >>> print(msg['precedence']) junk @@ -120,7 +120,7 @@ the recipient headers so that users will be able to reply back to the list. ... ... """) >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com X-Mailman-Version: ... Precedence: list diff --git a/src/mailman/handlers/docs/decorate.rst b/src/mailman/handlers/docs/decorate.rst index eae8ea904..bc98d3d28 100644 --- a/src/mailman/handlers/docs/decorate.rst +++ b/src/mailman/handlers/docs/decorate.rst @@ -24,13 +24,13 @@ decorations are added for digest messages. >>> from mailman.handlers.decorate import process >>> process(mlist, msg, dict(isdigest=True)) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.org Here is a message. >>> process(mlist, msg, dict(nodecorate=True)) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.org Here is a message. @@ -56,10 +56,10 @@ footer for all mailing lists in our site. >>> myheader_path = os.path.join(site_dir, 'myheader.txt') >>> with open(myheader_path, 'w') as fp: - ... print >> fp, 'header' + ... print('header', file=fp) >>> myfooter_path = os.path.join(site_dir, 'myfooter.txt') >>> with open(myfooter_path, 'w') as fp: - ... print >> fp, 'footer' + ... print('footer', file=fp) Setting these attributes on the mailing list causes it to use these templates. Since these are site-global templates, we can use a shorter path. @@ -74,7 +74,7 @@ Mailman to simply prepend the header and append the footer verbatim. >>> mlist.preferred_language = 'en' >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.org ... @@ -89,14 +89,14 @@ short descriptive name for the mailing list). :: >>> with open(myheader_path, 'w') as fp: - ... print >> fp, '$display_name header' + ... print('$display_name header', file=fp) >>> with open(myfooter_path, 'w') as fp: - ... print >> fp, '$display_name footer' + ... print('$display_name footer', file=fp) >>> msg = message_from_string(msg_text) >>> mlist.display_name = 'XTest' >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.org ... XTest header @@ -108,13 +108,13 @@ will remain in the header or footer unchanged. :: >>> with open(myheader_path, 'w') as fp: - ... print >> fp, '$dummy header' + ... print('$dummy header', file=fp) >>> with open(myfooter_path, 'w') as fp: - ... print >> fp, '$dummy footer' + ... print('$dummy footer', file=fp) >>> msg = message_from_string(msg_text) >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.org ... $dummy header @@ -137,9 +137,9 @@ message payload. :: >>> with open(myheader_path, 'w') as fp: - ... print >> fp, 'header' + ... print('header', file=fp) >>> with open(myfooter_path, 'w') as fp: - ... print >> fp, 'footer' + ... print('footer', file=fp) >>> mlist.preferred_language = 'en' >>> msg = message_from_string("""\ @@ -153,10 +153,10 @@ message payload. >>> # Don't use 'print' here as above because it won't be obvious from the >>> # output that the soft-line break space at the end of the 'Here is a >>> # message' line will be retained in the output. - >>> print msg['content-type'] + >>> print(msg['content-type']) text/plain; format="flowed"; delsp="no"; charset="us-ascii" >>> for line in msg.get_payload().splitlines(): - ... print '>{0}<'.format(line) + ... print('>{0}<'.format(line)) >header< >Here is a message < >with soft line breaks.< @@ -176,22 +176,22 @@ convert the text to utf-8 and base-64 encode the message payload. >>> mlist.preferred_language = 'ja' >>> with open(myheader_path, 'w') as fp: - ... print >> fp, '$description header' + ... print('$description header', file=fp) >>> with open(myfooter_path, 'w') as fp: - ... print >> fp, '$description footer' + ... print('$description footer', file=fp) >>> mlist.description = '\u65e5\u672c\u8a9e' >>> from email.message import Message >>> msg = Message() >>> msg.set_payload('Fran\xe7aise', 'iso-8859-1') - >>> print msg.as_string() + >>> print(msg.as_string()) MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Fran=E7aise >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 @@ -205,9 +205,9 @@ attachments. >>> mlist.preferred_language = 'en' >>> with open(myheader_path, 'w') as fp: - ... print >> fp, 'header' + ... print('header', file=fp) >>> with open(myfooter_path, 'w') as fp: - ... print >> fp, 'footer' + ... print('footer', file=fp) >>> msg = message_from_string("""\ ... From: aperson@example.org @@ -219,7 +219,7 @@ attachments. >>> process(mlist, msg, {}) >>> msg.set_boundary('BOUNDARY') - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.org Content-Type: multipart/mixed; boundary="BOUNDARY" @@ -272,7 +272,7 @@ as if they were simply concatenated. >>> msg = MIMEMultipart('mixed', boundary='BOUNDARY', ... _subparts=(part_1, part_2)) >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) Content-Type: multipart/mixed; boundary="BOUNDARY" MIME-Version: 1.0 @@ -317,7 +317,7 @@ so that the header and footer can be added as attachments. ... """) >>> process(mlist, msg, {}) >>> msg.set_boundary('BOUNDARY') - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.org ... --BOUNDARY diff --git a/src/mailman/handlers/docs/digests.rst b/src/mailman/handlers/docs/digests.rst index d4d563180..ac6ea33d6 100644 --- a/src/mailman/handlers/docs/digests.rst +++ b/src/mailman/handlers/docs/digests.rst @@ -100,7 +100,7 @@ The digest has been moved to a unique file. >>> from mailman.testing.helpers import get_queue_messages >>> item = get_queue_messages('digest')[0] >>> for msg in Mailbox(item.msgdata['digest_path']): - ... print msg['subject'] + ... print(msg['subject']) Test message 2 Test message 3 Test message 4 diff --git a/src/mailman/handlers/docs/file-recips.rst b/src/mailman/handlers/docs/file-recips.rst index 7d157ccc5..58af6f480 100644 --- a/src/mailman/handlers/docs/file-recips.rst +++ b/src/mailman/handlers/docs/file-recips.rst @@ -25,7 +25,7 @@ returns. >>> handler = config.handlers['file-recipients'] >>> handler.process(mlist, msg, msgdata) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com A message. @@ -63,12 +63,12 @@ addresses are returned as the set of recipients. >>> fp = open(file_path, 'w') >>> try: - ... print >> fp, 'bperson@example.com' - ... print >> fp, 'cperson@example.com' - ... print >> fp, 'dperson@example.com' - ... print >> fp, 'eperson@example.com' - ... print >> fp, 'fperson@example.com' - ... print >> fp, 'gperson@example.com' + ... print('bperson@example.com', file=fp) + ... print('cperson@example.com', file=fp) + ... print('dperson@example.com', file=fp) + ... print('eperson@example.com', file=fp) + ... print('fperson@example.com', file=fp) + ... print('gperson@example.com', file=fp) ... finally: ... fp.close() diff --git a/src/mailman/handlers/docs/filtering.rst b/src/mailman/handlers/docs/filtering.rst index fd0b33d3b..6c3735f1b 100644 --- a/src/mailman/handlers/docs/filtering.rst +++ b/src/mailman/handlers/docs/filtering.rst @@ -53,7 +53,7 @@ short-circuits. >>> mlist.filter_content = False >>> msgdata = {} >>> process(mlist, msg, msgdata) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Content-Type: image/jpeg MIME-Version: 1.0 @@ -68,7 +68,7 @@ crafted internally by Mailman. >>> mlist.filter_content = True >>> msgdata = {'isdigest': True} >>> process(mlist, msg, msgdata) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Content-Type: image/jpeg MIME-Version: 1.0 @@ -105,7 +105,7 @@ just that subpart will be stripped. ... """) >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Content-Type: multipart/mixed; boundary=BOUNDARY MIME-Version: 1.0 @@ -162,7 +162,7 @@ removing the inner ``multipart/alternative`` so that the outer ... --BOUNDARY-- ... """) >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Content-Type: multipart/mixed; boundary=BOUNDARY MIME-Version: 1.0 @@ -199,7 +199,7 @@ promoted to being the outer part. ... """) >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Content-Type: text/plain X-Content-Filtered-By: Mailman/MimeDel ... @@ -239,11 +239,11 @@ name of the file containing the message payload to filter. >>> script_path = os.path.join(config.DATA_DIR, 'filter.py') >>> fp = open(script_path, 'w') >>> try: - ... print >> fp, """\ + ... print("""\ ... import sys ... print 'Converted text/html to text/plain' ... print 'Filename:', sys.argv[1] - ... """ + ... """, file=fp) ... finally: ... fp.close() >>> config.HTML_TO_PLAIN_TEXT_COMMAND = '%s %s %%(filename)s' % ( @@ -257,7 +257,7 @@ name of the file containing the message payload to filter. ... ... """) >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com MIME-Version: 1.0 Content-Type: text/plain @@ -316,7 +316,7 @@ so the entire inner ``multipart/mixed`` is discarded. ... --AAA-- ... """) >>> process(mlist, msg, {}) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Content-Type: multipart/mixed; boundary=AAA X-Content-Filtered-By: Mailman/MimeDel ... diff --git a/src/mailman/handlers/docs/nntp.rst b/src/mailman/handlers/docs/nntp.rst index c298fcb14..2dfc95ce1 100644 --- a/src/mailman/handlers/docs/nntp.rst +++ b/src/mailman/handlers/docs/nntp.rst @@ -55,7 +55,7 @@ messages are gated to. >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) Subject: An important message Something of great import. diff --git a/src/mailman/handlers/docs/reply-to.rst b/src/mailman/handlers/docs/reply-to.rst index d421e2dc5..1d41a1799 100644 --- a/src/mailman/handlers/docs/reply-to.rst +++ b/src/mailman/handlers/docs/reply-to.rst @@ -50,7 +50,7 @@ original message, the list's posting address simply gets inserted. >>> process(mlist, msg, {}) >>> len(msg.get_all('reply-to')) 1 - >>> print msg['reply-to'] + >>> print(msg['reply-to']) _xtest@example.com It's also possible to strip any existing ``Reply-To`` header first, before @@ -65,7 +65,7 @@ adding the list's posting address. >>> process(mlist, msg, {}) >>> len(msg.get_all('reply-to')) 1 - >>> print msg['reply-to'] + >>> print(msg['reply-to']) _xtest@example.com If you don't first strip the header, then the list's posting address will just @@ -80,7 +80,7 @@ get appended to whatever the original version was. >>> process(mlist, msg, {}) >>> len(msg.get_all('reply-to')) 1 - >>> print msg['reply-to'] + >>> print(msg['reply-to']) bperson@example.com, _xtest@example.com @@ -98,7 +98,7 @@ The list can also be configured to have an explicit ``Reply-To`` header. >>> process(mlist, msg, {}) >>> len(msg.get_all('reply-to')) 1 - >>> print msg['reply-to'] + >>> print(msg['reply-to']) my-list@example.com And as before, it's possible to either strip any existing ``Reply-To`` @@ -113,7 +113,7 @@ header... >>> process(mlist, msg, {}) >>> len(msg.get_all('reply-to')) 1 - >>> print msg['reply-to'] + >>> print(msg['reply-to']) my-list@example.com ...or not. @@ -127,5 +127,5 @@ header... >>> process(mlist, msg, {}) >>> len(msg.get_all('reply-to')) 1 - >>> print msg['reply-to'] + >>> print(msg['reply-to']) my-list@example.com, bperson@example.com diff --git a/src/mailman/handlers/docs/replybot.rst b/src/mailman/handlers/docs/replybot.rst index 2793e4f75..638c2fdc8 100644 --- a/src/mailman/handlers/docs/replybot.rst +++ b/src/mailman/handlers/docs/replybot.rst @@ -55,7 +55,7 @@ response. reduced_list_headers: True version : 3 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit @@ -147,7 +147,7 @@ Unless the ``X-Ack:`` header has a value of ``yes``, in which case, the reduced_list_headers: True version : 3 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit @@ -186,7 +186,7 @@ will get auto-responses: those sent to the ``-request`` address... >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit @@ -219,7 +219,7 @@ will get auto-responses: those sent to the ``-request`` address... >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit @@ -258,14 +258,14 @@ measured in days. This is the first response to bperson, so it gets sent. >>> handler.process(mlist, msg, dict(to_owner=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 1 But with a grace period greater than zero, no subsequent response will be sent right now. >>> handler.process(mlist, msg, dict(to_owner=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 0 Fast forward 9 days and you still don't get a response. @@ -275,14 +275,14 @@ Fast forward 9 days and you still don't get a response. >>> factory.fast_forward(days=9) >>> handler.process(mlist, msg, dict(to_owner=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 0 But tomorrow, the sender will get a new auto-response. >>> factory.fast_forward() >>> handler.process(mlist, msg, dict(to_owner=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 1 Of course, everything works the same way for messages to the request @@ -297,21 +297,21 @@ address, even if the sender is the same person... ... """) >>> handler.process(mlist, msg, dict(to_request=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 1 >>> handler.process(mlist, msg, dict(to_request=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 0 >>> factory.fast_forward(days=9) >>> handler.process(mlist, msg, dict(to_request=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 0 >>> factory.fast_forward() >>> handler.process(mlist, msg, dict(to_request=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 1 ...and for messages to the posting address. @@ -325,19 +325,19 @@ address, even if the sender is the same person... ... """) >>> handler.process(mlist, msg, dict(to_list=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 1 >>> handler.process(mlist, msg, dict(to_list=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 0 >>> factory.fast_forward(days=9) >>> handler.process(mlist, msg, dict(to_list=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 0 >>> factory.fast_forward() >>> handler.process(mlist, msg, dict(to_list=True)) - >>> print len(get_queue_messages('virgin')) + >>> len(get_queue_messages('virgin')) 1 diff --git a/src/mailman/handlers/docs/rfc-2369.rst b/src/mailman/handlers/docs/rfc-2369.rst index 7064de6bd..8180b0635 100644 --- a/src/mailman/handlers/docs/rfc-2369.rst +++ b/src/mailman/handlers/docs/rfc-2369.rst @@ -21,11 +21,11 @@ headers generally start with the `List-` prefix. ... only.add('archived-at') ... else: ... only = set(header.lower() for header in only) - ... print '---start---' + ... print('---start---') ... for header in sorted(only): ... for value in sorted(msg.get_all(header, ())): - ... print '%s: %s' % (header, value) - ... print '---end---' + ... print('%s: %s' % (header, value)) + ... print('---end---') The `rfc-2369` handler adds the `List-` headers. `List-Id` is always added. diff --git a/src/mailman/handlers/docs/subject-munging.rst b/src/mailman/handlers/docs/subject-munging.rst index f9e3b9abb..538ad99c7 100644 --- a/src/mailman/handlers/docs/subject-munging.rst +++ b/src/mailman/handlers/docs/subject-munging.rst @@ -36,7 +36,7 @@ The original subject header is stored in the message metadata. >>> msgdata['original_subject'] u'' - >>> print msg['subject'] + >>> print(msg['subject']) [XTest] (no subject) If the original message had a ``Subject`` header, then the prefix is inserted @@ -50,9 +50,9 @@ at the beginning of the header's value. ... """) >>> msgdata = {} >>> process(mlist, msg, msgdata) - >>> print msgdata['original_subject'] + >>> print(msgdata['original_subject']) Something important - >>> print msg['subject'] + >>> print(msg['subject']) [XTest] Something important ``Subject`` headers are not munged for digest messages. @@ -64,7 +64,7 @@ at the beginning of the header's value. ... A message of great import. ... """) >>> process(mlist, msg, dict(isdigest=True)) - >>> print msg['subject'] + >>> print(msg['subject']) Something important Nor are they munged for *fast tracked* messages, which are generally defined @@ -77,7 +77,7 @@ as messages that Mailman crafts internally. ... A message of great import. ... """) >>> process(mlist, msg, dict(_fasttrack=True)) - >>> print msg['subject'] + >>> print(msg['subject']) Something important If a ``Subject`` header already has a prefix, usually following a ``Re:`` @@ -91,7 +91,7 @@ front of the header text. ... A message of great import. ... """) >>> process(mlist, msg, {}) - >>> print msg['subject'] + >>> print(msg['subject']) [XTest] Re: Something important If the ``Subject`` header has a prefix at the front of the header text, that's @@ -105,7 +105,7 @@ option available in Mailman 3. ... A message of great import. ... """) >>> process(mlist, msg, {}) - >>> print msg['subject'] + >>> print(msg['subject']) [XTest] Re: Something important @@ -122,7 +122,7 @@ set than the encoded header. ... ... """) >>> process(mlist, msg, {}) - >>> print msg['subject'] + >>> print(msg['subject']) [XTest] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= >>> unicode(msg['subject']) u'[XTest] \u30e1\u30fc\u30eb\u30de\u30f3' @@ -143,7 +143,7 @@ placeholder to the subject prefix, this post id can be included in the prefix. ... ... """) >>> process(mlist, msg, {}) - >>> print msg['subject'] + >>> print(msg['subject']) [XTest 456] Something important This works even when the message is a reply, except that in this case, the @@ -155,7 +155,7 @@ id. ... ... """) >>> process(mlist, msg, {}) - >>> print msg['subject'] + >>> print(msg['subject']) [XTest 456] Re: Something important If the ``Subject`` header had old style prefixing, the prefix is moved to the @@ -166,7 +166,7 @@ front of the header text. ... ... """) >>> process(mlist, msg, {}) - >>> print msg['subject'] + >>> print(msg['subject']) [XTest 456] Re: Something important @@ -178,7 +178,7 @@ in the subject prefix, and the subject is encoded non-ASCII. ... ... """) >>> process(mlist, msg, {}) - >>> print msg['subject'] + >>> print(msg['subject']) [XTest 456] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= >>> unicode(msg['subject']) u'[XTest 456] \u30e1\u30fc\u30eb\u30de\u30f3' @@ -191,7 +191,7 @@ prefix, possibly with a different posting number. ... ... """) >>> process(mlist, msg, {}) - >>> print msg['subject'] + >>> print(msg['subject']) [XTest 456] Re: =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= .. @@ -206,7 +206,7 @@ As before, old style subject prefixes are re-ordered. ... ... """) >>> process(mlist, msg, {}) - >>> print msg['subject'] + >>> print(msg['subject']) [XTest 456] Re: =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= @@ -227,7 +227,7 @@ starting with '\n ' is generated by some version of Eudora Japanese edition. ... ... """) >>> process(mlist, msg, {}) - >>> print msg['subject'] + >>> print(msg['subject']) [XTest] Important message And again, with an RFC 2047 encoded header. @@ -243,5 +243,5 @@ And again, with an RFC 2047 encoded header. # XXX This one does not appear to work the same way as # test_subject_munging_prefix_crooked() in the old Python-based tests. I need # to get Tokio to look at this. - # >>> print msg['subject'] + # >>> print(msg['subject']) # [XTest] =?iso-2022-jp?b?IBskQiVhITwlayVeJXMbKEI=?= diff --git a/src/mailman/handlers/docs/tagger.rst b/src/mailman/handlers/docs/tagger.rst index b64b05c54..f3303b7ef 100644 --- a/src/mailman/handlers/docs/tagger.rst +++ b/src/mailman/handlers/docs/tagger.rst @@ -28,7 +28,7 @@ are defined. >>> from mailman.handlers.tagger import process >>> process(mlist, msg, msgdata) - >>> print msg.as_string() + >>> print(msg.as_string()) Subject: foobar Keywords: barbaz @@ -48,7 +48,7 @@ and the message metadata gets a key with a list of matching topic names. ... """) >>> msgdata = {} >>> process(mlist, msg, msgdata) - >>> print msg.as_string() + >>> print(msg.as_string()) Subject: foobar Keywords: barbaz X-Topics: bar fight @@ -76,7 +76,7 @@ lines are scanned. ... """) >>> msgdata = {} >>> process(mlist, msg, msgdata) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Subject: nothing Keywords: at all @@ -103,7 +103,7 @@ found. ... """) >>> msgdata = {} >>> process(mlist, msg, msgdata) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Subject: nothing Keywords: at all @@ -130,7 +130,7 @@ header. ... """) >>> msgdata = {} >>> process(mlist, msg, msgdata) - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Subject: nothing Keywords: at all @@ -158,7 +158,7 @@ When set to a negative number, all body lines will be scanned. >>> process(mlist, msg, msgdata) >>> # Rather than print out 100 X-Ignore: headers, let's just prove that >>> # the X-Topics: header exists, meaning that the tagger did its job. - >>> print msg['x-topics'] + >>> print(msg['x-topics']) bar fight >>> msgdata['topichits'] [u'bar fight'] @@ -187,7 +187,7 @@ text payload. ... """) >>> msgdata = {} >>> process(mlist, msg, msgdata) - >>> print msg.as_string() + >>> print(msg.as_string()) Subject: Was Keywords: Raw Content-Type: multipart/alternative; boundary="BOUNDARY" @@ -232,7 +232,7 @@ But the tagger will not descend into non-text parts. ... """) >>> msgdata = {} >>> process(mlist, msg, msgdata) - >>> print msg['x-topics'] + >>> print(msg['x-topics']) None >>> msgdata {} diff --git a/src/mailman/handlers/docs/to-outgoing.rst b/src/mailman/handlers/docs/to-outgoing.rst index 816aa4ca6..e87fd4f26 100644 --- a/src/mailman/handlers/docs/to-outgoing.rst +++ b/src/mailman/handlers/docs/to-outgoing.rst @@ -29,7 +29,7 @@ additional key set: the mailing list name. >>> messages = get_queue_messages('out') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) Subject: Here is a message Something of great import. diff --git a/src/mailman/interfaces/autorespond.py b/src/mailman/interfaces/autorespond.py index de0ff3348..8da2fc795 100644 --- a/src/mailman/interfaces/autorespond.py +++ b/src/mailman/interfaces/autorespond.py @@ -17,7 +17,7 @@ """Autoresponder.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/bounce.py b/src/mailman/interfaces/bounce.py index 0cee88b6a..8a0ffd4b2 100644 --- a/src/mailman/interfaces/bounce.py +++ b/src/mailman/interfaces/bounce.py @@ -17,7 +17,7 @@ """Interface to bounce detection components.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/chain.py b/src/mailman/interfaces/chain.py index 1b6531d2e..85bad22a4 100644 --- a/src/mailman/interfaces/chain.py +++ b/src/mailman/interfaces/chain.py @@ -17,7 +17,7 @@ """Interfaces describing the basics of chains and links.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/command.py b/src/mailman/interfaces/command.py index 2a0656841..720e59ee8 100644 --- a/src/mailman/interfaces/command.py +++ b/src/mailman/interfaces/command.py @@ -17,7 +17,7 @@ """Interfaces defining email commands.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/digests.py b/src/mailman/interfaces/digests.py index 3abb5e57b..c5231e488 100644 --- a/src/mailman/interfaces/digests.py +++ b/src/mailman/interfaces/digests.py @@ -17,7 +17,7 @@ """One last digest.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/domain.py b/src/mailman/interfaces/domain.py index d8f8ec100..e8610fd76 100644 --- a/src/mailman/interfaces/domain.py +++ b/src/mailman/interfaces/domain.py @@ -17,7 +17,7 @@ """Interface representing domains.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/errors.py b/src/mailman/interfaces/errors.py index 0d3eef7e8..187c329b3 100644 --- a/src/mailman/interfaces/errors.py +++ b/src/mailman/interfaces/errors.py @@ -22,7 +22,7 @@ components. More specific exceptions will be located in the relevant interfaces. """ -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/languages.py b/src/mailman/interfaces/languages.py index 32c18fb7a..9e88dd78f 100644 --- a/src/mailman/interfaces/languages.py +++ b/src/mailman/interfaces/languages.py @@ -17,7 +17,7 @@ """Interfaces for managing languages.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/listmanager.py b/src/mailman/interfaces/listmanager.py index 068fe82dc..22d7b3418 100644 --- a/src/mailman/interfaces/listmanager.py +++ b/src/mailman/interfaces/listmanager.py @@ -17,7 +17,7 @@ """Interface for list storage, deleting, and finding.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/member.py b/src/mailman/interfaces/member.py index f5fe9438e..e2a5dc4fe 100644 --- a/src/mailman/interfaces/member.py +++ b/src/mailman/interfaces/member.py @@ -17,7 +17,7 @@ """Interface describing the basics of a member.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/messages.py b/src/mailman/interfaces/messages.py index 6b9db67d2..4980a4f9d 100644 --- a/src/mailman/interfaces/messages.py +++ b/src/mailman/interfaces/messages.py @@ -17,7 +17,7 @@ """The message storage service.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/mime.py b/src/mailman/interfaces/mime.py index 502fbca4e..4729c426c 100644 --- a/src/mailman/interfaces/mime.py +++ b/src/mailman/interfaces/mime.py @@ -17,7 +17,7 @@ """MIME content filtering.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/mlistrequest.py b/src/mailman/interfaces/mlistrequest.py index dc6a9463e..77451f8bf 100644 --- a/src/mailman/interfaces/mlistrequest.py +++ b/src/mailman/interfaces/mlistrequest.py @@ -17,7 +17,7 @@ """Interface for a web request accessing a mailing list.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/mta.py b/src/mailman/interfaces/mta.py index ccbef04cb..22c3d121e 100644 --- a/src/mailman/interfaces/mta.py +++ b/src/mailman/interfaces/mta.py @@ -17,7 +17,7 @@ """Interface for mail transport agent integration.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/pending.py b/src/mailman/interfaces/pending.py index 77045aafe..a97552306 100644 --- a/src/mailman/interfaces/pending.py +++ b/src/mailman/interfaces/pending.py @@ -22,7 +22,7 @@ maps these events to a unique hash that can be used as a token for end user confirmation. """ -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/permissions.py b/src/mailman/interfaces/permissions.py index 8e403e89c..8d06e9ffb 100644 --- a/src/mailman/interfaces/permissions.py +++ b/src/mailman/interfaces/permissions.py @@ -17,7 +17,7 @@ """Interfaces for various permissions.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/pipeline.py b/src/mailman/interfaces/pipeline.py index b7c933cac..817ebfc62 100644 --- a/src/mailman/interfaces/pipeline.py +++ b/src/mailman/interfaces/pipeline.py @@ -17,7 +17,7 @@ """Interface for describing pipelines.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/preferences.py b/src/mailman/interfaces/preferences.py index 4d9ef683f..27ae49faa 100644 --- a/src/mailman/interfaces/preferences.py +++ b/src/mailman/interfaces/preferences.py @@ -17,7 +17,7 @@ """Interface for preferences.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/registrar.py b/src/mailman/interfaces/registrar.py index 8a77ca8f6..413f3284e 100644 --- a/src/mailman/interfaces/registrar.py +++ b/src/mailman/interfaces/registrar.py @@ -22,7 +22,7 @@ etc. than the IUserManager. The latter does no validation, syntax checking, or confirmation, while this interface does. """ -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/requests.py b/src/mailman/interfaces/requests.py index 2df1b20fd..4dcb3cace 100644 --- a/src/mailman/interfaces/requests.py +++ b/src/mailman/interfaces/requests.py @@ -21,7 +21,7 @@ The request database handles events that must be approved by the list moderators, such as subscription requests and held messages. """ -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/roster.py b/src/mailman/interfaces/roster.py index 6a3e5c579..c4a7f5567 100644 --- a/src/mailman/interfaces/roster.py +++ b/src/mailman/interfaces/roster.py @@ -17,7 +17,7 @@ """Interface for a roster of members.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/rules.py b/src/mailman/interfaces/rules.py index 7de70dee3..feb773fca 100644 --- a/src/mailman/interfaces/rules.py +++ b/src/mailman/interfaces/rules.py @@ -17,7 +17,7 @@ """Interface describing the basics of rules.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/runner.py b/src/mailman/interfaces/runner.py index 8ad9000ce..9cb554597 100644 --- a/src/mailman/interfaces/runner.py +++ b/src/mailman/interfaces/runner.py @@ -17,7 +17,7 @@ """Interface for runners.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/styles.py b/src/mailman/interfaces/styles.py index f4c185cd2..33ab8ee84 100644 --- a/src/mailman/interfaces/styles.py +++ b/src/mailman/interfaces/styles.py @@ -17,7 +17,7 @@ """Interfaces for list styles.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/subscriptions.py b/src/mailman/interfaces/subscriptions.py index 456ae7be1..64d4280d6 100644 --- a/src/mailman/interfaces/subscriptions.py +++ b/src/mailman/interfaces/subscriptions.py @@ -17,7 +17,7 @@ """Membership interface for REST.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/switchboard.py b/src/mailman/interfaces/switchboard.py index 36f0644be..ae613700a 100644 --- a/src/mailman/interfaces/switchboard.py +++ b/src/mailman/interfaces/switchboard.py @@ -17,7 +17,7 @@ """Interface for switchboards.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/system.py b/src/mailman/interfaces/system.py index 999878aa0..83992629c 100644 --- a/src/mailman/interfaces/system.py +++ b/src/mailman/interfaces/system.py @@ -17,7 +17,7 @@ """System information.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/interfaces/usermanager.py b/src/mailman/interfaces/usermanager.py index b06043c78..f37d39f6a 100644 --- a/src/mailman/interfaces/usermanager.py +++ b/src/mailman/interfaces/usermanager.py @@ -17,7 +17,7 @@ """Interface describing the user management service.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/model/docs/addresses.rst b/src/mailman/model/docs/addresses.rst index b29ae658b..795afe43c 100644 --- a/src/mailman/model/docs/addresses.rst +++ b/src/mailman/model/docs/addresses.rst @@ -29,7 +29,7 @@ Creating an unlinked email address is straightforward. However, such addresses have no real name. - >>> print address_1.display_name + >>> print(address_1.display_name) You can also create an email address object with a real name. @@ -46,9 +46,9 @@ You can also create an email address object with a real name. The ``str()`` of the address is the RFC 2822 preferred originator format, while the ``repr()`` carries more information. - >>> print str(address_2) + >>> print(str(address_2)) Ben Person - >>> print repr(address_2) + >>> print(repr(address_2)) [not verified] at 0x...> You can assign real names to existing addresses. @@ -61,9 +61,9 @@ You can assign real names to existing addresses. These addresses are not linked to users, and can be seen by searching the user manager for an associated user. - >>> print user_manager.get_user('aperson@example.com') + >>> print(user_manager.get_user('aperson@example.com')) None - >>> print user_manager.get_user('bperson@example.com') + >>> print(user_manager.get_user('bperson@example.com')) None You can create email addresses that are linked to users by using a different @@ -84,9 +84,9 @@ interface. And now you can find the associated user. - >>> print user_manager.get_user('aperson@example.com') + >>> print(user_manager.get_user('aperson@example.com')) None - >>> print user_manager.get_user('bperson@example.com') + >>> print(user_manager.get_user('bperson@example.com')) None >>> user_manager.get_user('cperson@example.com') @@ -131,9 +131,9 @@ but the latter must be set explicitly. >>> address_4 = user_manager.create_address( ... 'dperson@example.com', 'Dan Person') - >>> print address_4.registered_on + >>> print(address_4.registered_on) 2005-08-01 07:49:23 - >>> print address_4.verified_on + >>> print(address_4.verified_on) None The verification date records when the user has completed a mail-back @@ -141,7 +141,7 @@ verification procedure. It takes a datetime object. >>> from mailman.utilities.datetime import now >>> address_4.verified_on = now() - >>> print address_4.verified_on + >>> print(address_4.verified_on) 2005-08-01 07:49:23 The address shows the verified status in its representation. @@ -160,7 +160,7 @@ An event is triggered when the address gets verified. >>> from mailman.testing.helpers import event_subscribers >>> with event_subscribers(save_event): ... address_5.verified_on = now() - >>> print saved_event + >>> print(saved_event) An event is also triggered when the address is unverified. In this case, @@ -169,9 +169,9 @@ address is being unverified. >>> with event_subscribers(save_event): ... address_5.verified_on = None - >>> print saved_event + >>> print(saved_event) - >>> print saved_event.address.verified_on + >>> print(saved_event.address.verified_on) None @@ -190,18 +190,18 @@ The str() of such an address prints the RFC 2822 preferred originator format with the original case-preserved address. The repr() contains all the gory details. - >>> print str(address_6) + >>> print(str(address_6)) Frank Person - >>> print repr(address_6) + >>> print(repr(address_6)) [not verified] key: fperson@example.com at 0x...> Both the case-insensitive version of the address and the original case-preserved version are available on attributes of the `IAddress` object. - >>> print address_6.email + >>> print(address_6.email) fperson@example.com - >>> print address_6.original_email + >>> print(address_6.original_email) FPERSON@example.com Because addresses are case-insensitive for all other purposes, you cannot @@ -223,7 +223,7 @@ create an address that differs only in case. You can get the address using either the lower cased version or case-preserved version. In fact, searching for an address is case insensitive. - >>> print user_manager.get_address('fperson@example.com').email + >>> print(user_manager.get_address('fperson@example.com').email) fperson@example.com - >>> print user_manager.get_address('FPERSON@example.com').email + >>> print(user_manager.get_address('FPERSON@example.com').email) fperson@example.com diff --git a/src/mailman/model/docs/autorespond.rst b/src/mailman/model/docs/autorespond.rst index b2bf03ed9..6210e48cb 100644 --- a/src/mailman/model/docs/autorespond.rst +++ b/src/mailman/model/docs/autorespond.rst @@ -112,5 +112,5 @@ If there's been no response sent to a particular address, None is returned. ... 'bperson@example.com') >>> response_set.todays_count(address, Response.command) 0 - >>> print response_set.last_response(address, Response.command) + >>> print(response_set.last_response(address, Response.command)) None diff --git a/src/mailman/model/docs/bounce.rst b/src/mailman/model/docs/bounce.rst index f427689bd..c5123fdef 100644 --- a/src/mailman/model/docs/bounce.rst +++ b/src/mailman/model/docs/bounce.rst @@ -39,16 +39,16 @@ of bouncing email addresses. These are passed one-by-one to the registration interface. >>> event = processor.register(mlist, 'anne@example.com', msg) - >>> print event.list_id + >>> print(event.list_id) test.example.com - >>> print event.email + >>> print(event.email) anne@example.com - >>> print event.message_id + >>> print(event.message_id) Bounce events have a timestamp. - >>> print event.timestamp + >>> print(event.timestamp) 2005-08-01 07:49:23 Bounce events have a flag indicating whether they've been processed or not. @@ -68,9 +68,9 @@ When a bounce is registered, you can indicate the bounce context. If no context is given, then a default one is used. >>> event = processor.register(mlist, 'bart@example.com', msg) - >>> print event.message_id + >>> print(event.message_id) - >>> print event.context + >>> print(event.context) BounceContext.normal A probe bounce carries more weight than just a normal bounce. @@ -78,7 +78,7 @@ A probe bounce carries more weight than just a normal bounce. >>> from mailman.interfaces.bounce import BounceContext >>> event = processor.register( ... mlist, 'bart@example.com', msg, BounceContext.probe) - >>> print event.message_id + >>> print(event.message_id) - >>> print event.context + >>> print(event.context) BounceContext.probe diff --git a/src/mailman/model/docs/domains.rst b/src/mailman/model/docs/domains.rst index 878e5835a..153f6c19d 100644 --- a/src/mailman/model/docs/domains.rst +++ b/src/mailman/model/docs/domains.rst @@ -16,10 +16,10 @@ Domains are how Mailman interacts with email host names and web host names. >>> from operator import attrgetter >>> def show_domains(): ... if len(manager) == 0: - ... print 'no domains' + ... print('no domains') ... return ... for domain in sorted(manager, key=attrgetter('mail_host')): - ... print domain + ... print(domain) >>> show_domains() no domains @@ -77,9 +77,9 @@ Domains can list all associated mailing lists with the mailing_lists property. >>> def show_lists(domain): ... mlists = list(domain.mailing_lists) ... for mlist in mlists: - ... print mlist + ... print(mlist) ... if len(mlists) == 0: - ... print 'no lists' + ... print('no lists') >>> net_domain = manager['example.net'] >>> com_domain = manager['example.com'] @@ -99,16 +99,16 @@ In the global domain manager, domains are indexed by their email host name. :: >>> for domain in sorted(manager, key=attrgetter('mail_host')): - ... print domain.mail_host + ... print(domain.mail_host) example.com example.net - >>> print manager['example.net'] + >>> print(manager['example.net']) - >>> print manager['doesnotexist.com'] + >>> print(manager['doesnotexist.com']) Traceback (most recent call last): ... KeyError: u'doesnotexist.com' @@ -117,15 +117,15 @@ As with a dictionary, you can also get the domain. If the domain does not exist, ``None`` or a default is returned. :: - >>> print manager.get('example.net') + >>> print(manager.get('example.net')) - >>> print manager.get('doesnotexist.com') + >>> print(manager.get('doesnotexist.com')) None - >>> print manager.get('doesnotexist.com', 'blahdeblah') + >>> print(manager.get('doesnotexist.com', 'blahdeblah')) blahdeblah Non-existent domains cannot be removed. @@ -143,5 +143,5 @@ Confirmation tokens can be added to the domain's url to generate the URL to a page users can use to confirm their subscriptions. >>> domain = manager['example.net'] - >>> print domain.confirm_url('abc') + >>> print(domain.confirm_url('abc')) http://lists.example.net/confirm/abc diff --git a/src/mailman/model/docs/languages.rst b/src/mailman/model/docs/languages.rst index 06af71417..fedea0e6e 100644 --- a/src/mailman/model/docs/languages.rst +++ b/src/mailman/model/docs/languages.rst @@ -44,13 +44,13 @@ used by the language. The language object is returned. And you can get information for all known languages. - >>> print mgr['en'].description + >>> print(mgr['en'].description) English - >>> print mgr['en'].charset + >>> print(mgr['en'].charset) us-ascii - >>> print mgr['it'].description + >>> print(mgr['it'].description) Italian - >>> print mgr['it'].charset + >>> print(mgr['it'].charset) iso-8859-1 @@ -70,7 +70,7 @@ You can iterate over all the known languages. >>> languages = sorted((language for language in mgr.languages), ... key=attrgetter('code')) >>> for language in languages: - ... print language.code, language.charset, language.description + ... print(language.code, language.charset, language.description) en us-ascii English it iso-8859-1 Italian pl iso-8859-2 Polish @@ -84,17 +84,17 @@ You can ask whether a particular language code is known. You can get a particular language by its code. - >>> print mgr['it'].description + >>> print(mgr['it'].description) Italian - >>> print mgr['xx'].code + >>> print(mgr['xx'].code) Traceback (most recent call last): ... KeyError: u'xx' - >>> print mgr.get('it').description + >>> print(mgr.get('it').description) Italian - >>> print mgr.get('xx') + >>> print(mgr.get('xx')) None - >>> print mgr.get('xx', 'missing') + >>> print(mgr.get('xx', 'missing')) missing diff --git a/src/mailman/model/docs/listmanager.rst b/src/mailman/model/docs/listmanager.rst index 41450b15d..151bee1fe 100644 --- a/src/mailman/model/docs/listmanager.rst +++ b/src/mailman/model/docs/listmanager.rst @@ -25,13 +25,13 @@ listname, and an `RFC 2369`_ list id. This latter will not change even if the mailing list moves to a different host, so it is what uniquely distinguishes the mailing list to the system. - >>> print mlist.list_name + >>> print(mlist.list_name) test - >>> print mlist.mail_host + >>> print(mlist.mail_host) example.com - >>> print mlist.fqdn_listname + >>> print(mlist.fqdn_listname) test@example.com - >>> print mlist.list_id + >>> print(mlist.list_id) test.example.com If you try to create a mailing list with the same name as an existing list, @@ -63,7 +63,7 @@ Use the list manager to delete a mailing list. After deleting the list, you can create it again. >>> mlist = list_manager.create('test@example.com') - >>> print mlist.fqdn_listname + >>> print(mlist.fqdn_listname) test@example.com @@ -85,14 +85,14 @@ You can also get a mailing list by it's list id. If you try to get a list that doesn't existing yet, you get ``None``. - >>> print list_manager.get('test_2@example.com') + >>> print(list_manager.get('test_2@example.com')) None - >>> print list_manager.get_by_list_id('test_2.example.com') + >>> print(list_manager.get_by_list_id('test_2.example.com')) None You also get ``None`` if the list name is invalid. - >>> print list_manager.get('foo') + >>> print(list_manager.get('foo')) None @@ -108,26 +108,26 @@ address components. >>> mlist_4 = list_manager.create('test_4@example.com') >>> for name in sorted(list_manager.names): - ... print name + ... print(name) test@example.com test_3@example.com test_4@example.com >>> for list_id in sorted(list_manager.list_ids): - ... print list_id + ... print(list_id) test.example.com test_3.example.com test_4.example.com >>> for fqdn_listname in sorted(m.fqdn_listname ... for m in list_manager.mailing_lists): - ... print fqdn_listname + ... print(fqdn_listname) test@example.com test_3@example.com test_4@example.com >>> for list_name, mail_host in sorted(list_manager.name_components): - ... print list_name, '@', mail_host + ... print(list_name, '@', mail_host) test @ example.com test_3 @ example.com test_4 @ example.com diff --git a/src/mailman/model/docs/mailinglist.rst b/src/mailman/model/docs/mailinglist.rst index 21c2f0fd8..53ba99575 100644 --- a/src/mailman/model/docs/mailinglist.rst +++ b/src/mailman/model/docs/mailinglist.rst @@ -10,17 +10,17 @@ i.e. the email address you would send a message to in order to post a message to the mailing list. The list id is defined in `RFC 2369`_. >>> mlist = create_list('aardvark@example.com') - >>> print mlist.list_id + >>> print(mlist.list_id) aardvark.example.com - >>> print mlist.fqdn_listname + >>> print(mlist.fqdn_listname) aardvark@example.com The mailing list also has convenient attributes for accessing the list's short name (i.e. local part) and host name. - >>> print mlist.list_name + >>> print(mlist.list_name) aardvark - >>> print mlist.mail_host + >>> print(mlist.mail_host) example.com @@ -51,7 +51,7 @@ receive a copy of any message sent to the mailing list. Both addresses appear on the roster of members. >>> for member in mlist.members.members: - ... print member + ... print(member) @@ -73,12 +73,12 @@ an owner and a moderator. :: >>> for member in mlist.owners.members: - ... print member + ... print(member) >>> for member in mlist.moderators.members: - ... print member + ... print(member) @@ -88,19 +88,19 @@ All rosters can also be accessed indirectly. >>> roster = mlist.get_roster(MemberRole.member) >>> for member in roster.members: - ... print member + ... print(member) >>> roster = mlist.get_roster(MemberRole.owner) >>> for member in roster.members: - ... print member + ... print(member) >>> roster = mlist.get_roster(MemberRole.moderator) >>> for member in roster.members: - ... print member + ... print(member) @@ -123,7 +123,7 @@ just by changing their preferred address. on aardvark@example.com as MemberRole.member> >>> for member in mlist.members.members: - ... print member + ... print(member) on aardvark@example.com @@ -134,7 +134,7 @@ just by changing their preferred address. >>> user.preferred_address = new_address >>> for member in mlist.members.members: - ... print member + ... print(member) >> from zope.component import getUtility >>> user_manager = getUtility(IUserManager) >>> user_1 = user_manager.create_user('aperson@example.com', 'Anne Person') - >>> print user_1 + >>> print(user_1) We can add Anne as an owner of the mailing list, by creating a member role for @@ -70,7 +70,7 @@ her a moderator. Nor does it make her a member of the list. Bart becomes a moderator of the list. >>> user_2 = user_manager.create_user('bperson@example.com', 'Bart Person') - >>> print user_2 + >>> print(user_2) >>> address_2 = list(user_2.addresses)[0] >>> mlist.subscribe(address_2, MemberRole.moderator) @@ -200,13 +200,13 @@ text email address by using the ``IRoster.get_member()`` method. However, if the address is not subscribed with the appropriate role, then None is returned. - >>> print mlist.administrators.get_member('zperson@example.com') + >>> print(mlist.administrators.get_member('zperson@example.com')) None - >>> print mlist.moderators.get_member('aperson@example.com') + >>> print(mlist.moderators.get_member('aperson@example.com')) None - >>> print mlist.members.get_member('zperson@example.com') + >>> print(mlist.members.get_member('zperson@example.com')) None - >>> print mlist.nonmembers.get_member('aperson@example.com') + >>> print(mlist.nonmembers.get_member('aperson@example.com')) None @@ -219,7 +219,7 @@ regardless of their role. >>> def sortkey(member): ... return (member.address.email, member.role.value) >>> for member in sorted(mlist.subscribers.members, key=sortkey): - ... print member.address.email, member.role + ... print(member.address.email, member.role) aperson@example.com MemberRole.member aperson@example.com MemberRole.owner bperson@example.com MemberRole.member @@ -249,7 +249,7 @@ automatically accepted for posting to the mailing list. >>> for member in sorted(mlist.administrators.members, ... key=attrgetter('address.email')): - ... print member.address.email, member.role, member.moderation_action + ... print(member.address.email, member.role, member.moderation_action) aperson@example.com MemberRole.owner Action.accept bperson@example.com MemberRole.moderator Action.accept @@ -258,7 +258,7 @@ should go through the normal moderation checks. >>> for member in sorted(mlist.members.members, ... key=attrgetter('address.email')): - ... print member.address.email, member.role, member.moderation_action + ... print(member.address.email, member.role, member.moderation_action) aperson@example.com MemberRole.member Action.defer bperson@example.com MemberRole.member Action.defer cperson@example.com MemberRole.member Action.defer @@ -266,7 +266,7 @@ should go through the normal moderation checks. Postings by nonmembers are held for moderator approval by default. >>> for member in mlist.nonmembers.members: - ... print member.address.email, member.role, member.moderation_action + ... print(member.address.email, member.role, member.moderation_action) fperson@example.com MemberRole.nonmember Action.hold @@ -283,7 +283,7 @@ though that the address their changing to must be verified. >>> gwen_address = list(gwen.addresses)[0] >>> gwen_member = bee.subscribe(gwen_address) >>> for m in bee.members.members: - ... print m.member_id.int, m.mailing_list.list_id, m.address.email + ... print(m.member_id.int, m.mailing_list.list_id, m.address.email) 7 bee.example.com gwen@example.com Gwen gets a email address. @@ -301,7 +301,7 @@ address, but the address is not yet verified. Her membership has not changed. >>> for m in bee.members.members: - ... print m.member_id.int, m.mailing_list.list_id, m.address.email + ... print(m.member_id.int, m.mailing_list.list_id, m.address.email) 7 bee.example.com gwen@example.com Gwen verifies her email address, and updates her membership. @@ -313,7 +313,7 @@ Gwen verifies her email address, and updates her membership. Now her membership reflects the new address. >>> for m in bee.members.members: - ... print m.member_id.int, m.mailing_list.list_id, m.address.email + ... print(m.member_id.int, m.mailing_list.list_id, m.address.email) 7 bee.example.com gperson@example.com @@ -325,7 +325,7 @@ An event is triggered when a new member is subscribed to a mailing list. >>> from mailman.testing.helpers import event_subscribers >>> def handle_event(event): - ... print event + ... print(event) >>> cat = create_list('cat@example.com') >>> herb = user_manager.create_address('herb@example.com') diff --git a/src/mailman/model/docs/messagestore.rst b/src/mailman/model/docs/messagestore.rst index 3ee59129b..4ddce7606 100644 --- a/src/mailman/model/docs/messagestore.rst +++ b/src/mailman/model/docs/messagestore.rst @@ -30,7 +30,7 @@ However, if the message has a ``Message-ID`` header, it can be stored. >>> msg['Message-ID'] = '<87myycy5eh.fsf@uwakimon.sk.tsukuba.ac.jp>' >>> message_store.add(msg) 'AGDWSNXXKCWEILKKNYTBOHRDQGOX3Y35' - >>> print msg.as_string() + >>> print(msg.as_string()) Subject: An important message Message-ID: <87myycy5eh.fsf@uwakimon.sk.tsukuba.ac.jp> X-Message-ID-Hash: AGDWSNXXKCWEILKKNYTBOHRDQGOX3Y35 @@ -46,15 +46,15 @@ There are several ways to find a message given either the ``Message-ID`` or ``X-Message-ID-Hash`` headers. In either case, if no matching message is found, ``None`` is returned. - >>> print message_store.get_message_by_id('nothing') + >>> print(message_store.get_message_by_id('nothing')) None - >>> print message_store.get_message_by_hash('nothing') + >>> print(message_store.get_message_by_hash('nothing')) None Given an existing ``Message-ID``, the message can be found. >>> message = message_store.get_message_by_id(msg['message-id']) - >>> print message.as_string() + >>> print(message.as_string()) Subject: An important message Message-ID: <87myycy5eh.fsf@uwakimon.sk.tsukuba.ac.jp> X-Message-ID-Hash: AGDWSNXXKCWEILKKNYTBOHRDQGOX3Y35 @@ -65,7 +65,7 @@ Given an existing ``Message-ID``, the message can be found. Similarly, we can find messages by the ``X-Message-ID-Hash``: >>> message = message_store.get_message_by_hash(msg['x-message-id-hash']) - >>> print message.as_string() + >>> print(message.as_string()) Subject: An important message Message-ID: <87myycy5eh.fsf@uwakimon.sk.tsukuba.ac.jp> X-Message-ID-Hash: AGDWSNXXKCWEILKKNYTBOHRDQGOX3Y35 @@ -83,7 +83,7 @@ contains. >>> messages = list(message_store.messages) >>> len(messages) 1 - >>> print messages[0].as_string() + >>> print(messages[0].as_string()) Subject: An important message Message-ID: <87myycy5eh.fsf@uwakimon.sk.tsukuba.ac.jp> X-Message-ID-Hash: AGDWSNXXKCWEILKKNYTBOHRDQGOX3Y35 @@ -110,7 +110,7 @@ But if you delete an existing message, it really gets deleted. >>> message_store.delete_message(message_id) >>> list(message_store.messages) [] - >>> print message_store.get_message_by_id(message_id) + >>> print(message_store.get_message_by_id(message_id)) None - >>> print message_store.get_message_by_hash(message['x-message-id-hash']) + >>> print(message_store.get_message_by_hash(message['x-message-id-hash'])) None diff --git a/src/mailman/model/docs/mlist-addresses.rst b/src/mailman/model/docs/mlist-addresses.rst index 2a021f67f..d546b4962 100644 --- a/src/mailman/model/docs/mlist-addresses.rst +++ b/src/mailman/model/docs/mlist-addresses.rst @@ -10,48 +10,48 @@ These are defined in the ``IMailingListAddresses`` interface. The posting address is where people send messages to be posted to the mailing list. This is exactly the same as the fully qualified list name. - >>> print mlist.fqdn_listname + >>> print(mlist.fqdn_listname) _xtest@example.com - >>> print mlist.posting_address + >>> print(mlist.posting_address) _xtest@example.com Messages to the mailing list's `no reply` address always get discarded without prejudice. - >>> print mlist.no_reply_address + >>> print(mlist.no_reply_address) noreply@example.com The mailing list's owner address reaches the human moderators. - >>> print mlist.owner_address + >>> print(mlist.owner_address) _xtest-owner@example.com The request address goes to the list's email command robot. - >>> print mlist.request_address + >>> print(mlist.request_address) _xtest-request@example.com The bounces address accepts and processes all potential bounces. - >>> print mlist.bounces_address + >>> print(mlist.bounces_address) _xtest-bounces@example.com The join (a.k.a. subscribe) address is where someone can email to get added to the mailing list. The subscribe alias is a synonym for join, but it's deprecated. - >>> print mlist.join_address + >>> print(mlist.join_address) _xtest-join@example.com - >>> print mlist.subscribe_address + >>> print(mlist.subscribe_address) _xtest-subscribe@example.com The leave (a.k.a. unsubscribe) address is where someone can email to get added to the mailing list. The unsubscribe alias is a synonym for leave, but it's deprecated. - >>> print mlist.leave_address + >>> print(mlist.leave_address) _xtest-leave@example.com - >>> print mlist.unsubscribe_address + >>> print(mlist.unsubscribe_address) _xtest-unsubscribe@example.com @@ -64,15 +64,15 @@ included in the local part of the email address. The exact format of this is dependent on the ``verp_confirm_format`` configuration variable. :: - >>> print mlist.confirm_address('cookie') + >>> print(mlist.confirm_address('cookie')) _xtest-confirm+cookie@example.com - >>> print mlist.confirm_address('wookie') + >>> print(mlist.confirm_address('wookie')) _xtest-confirm+wookie@example.com >>> config.push('test config', """ ... [mta] ... verp_confirm_format: $address---$cookie ... """) - >>> print mlist.confirm_address('cookie') + >>> print(mlist.confirm_address('cookie')) _xtest-confirm---cookie@example.com >>> config.pop('test config') diff --git a/src/mailman/model/docs/pending.rst b/src/mailman/model/docs/pending.rst index 3d33dd5da..d8206b264 100644 --- a/src/mailman/model/docs/pending.rst +++ b/src/mailman/model/docs/pending.rst @@ -39,7 +39,7 @@ the database that matches the token. If the token isn't in the database, None is returned. >>> pendable = pendingdb.confirm(bytes('missing')) - >>> print pendable + >>> print(pendable) None >>> pendable = pendingdb.confirm(token) >>> dump_msgdata(pendable) @@ -51,7 +51,7 @@ is returned. After confirmation, the token is no longer in the database. - >>> print pendingdb.confirm(token) + >>> print(pendingdb.confirm(token)) None There are a few other things you can do with the pending database. When you @@ -70,7 +70,7 @@ expunge it. >>> pendable = pendingdb.confirm(token_1, expunge=True) >>> dump_msgdata(pendable) type: one - >>> print pendingdb.confirm(token_1) + >>> print(pendingdb.confirm(token_1)) None An event can be given a lifetime when it is pended, otherwise it just uses a @@ -84,7 +84,7 @@ default lifetime. Every once in a while the pending database is cleared of old records. >>> pendingdb.evict() - >>> print pendingdb.confirm(token_4) + >>> print(pendingdb.confirm(token_4)) None >>> pendable = pendingdb.confirm(token_2) >>> dump_msgdata(pendable) diff --git a/src/mailman/model/docs/registration.rst b/src/mailman/model/docs/registration.rst index 77cb75890..32ee27316 100644 --- a/src/mailman/model/docs/registration.rst +++ b/src/mailman/model/docs/registration.rst @@ -22,7 +22,7 @@ Here is a helper function to check the token strings. ... assert isinstance(token, basestring), 'Not a string' ... assert len(token) == 40, 'Unexpected length: %d' % len(token) ... assert token.isalnum(), 'Not alphanumeric' - ... print 'ok' + ... print('ok') Here is a helper function to extract tokens from confirmation messages. @@ -90,9 +90,9 @@ There should be no records in the user manager for this address yet. >>> from mailman.interfaces.usermanager import IUserManager >>> from zope.component import getUtility >>> user_manager = getUtility(IUserManager) - >>> print user_manager.get_user('aperson@example.com') + >>> print(user_manager.get_user('aperson@example.com')) None - >>> print user_manager.get_address('aperson@example.com') + >>> print(user_manager.get_address('aperson@example.com')) None But this address is waiting for confirmation. @@ -118,7 +118,7 @@ message is sent to the user in order to verify the registered address. >>> items = get_queue_messages('virgin') >>> len(items) 1 - >>> print items[0].msg.as_string() + >>> print(items[0].msg.as_string()) MIME-Version: 1.0 ... Subject: confirm ... @@ -224,7 +224,7 @@ confirmation step is completed. >>> token = registrar.register( ... mlist, 'cperson@example.com', 'Claire Person') - >>> print user_manager.get_user('cperson@example.com') + >>> print(user_manager.get_user('cperson@example.com')) None >>> items = get_queue_messages('virgin') >>> len(items) @@ -256,11 +256,11 @@ mind about registering. When discarded, no `IAddress` or `IUser` is created. >>> check_token(token) ok >>> registrar.discard(token) - >>> print pendingdb.confirm(token) + >>> print(pendingdb.confirm(token)) None - >>> print user_manager.get_address('eperson@example.com') + >>> print(user_manager.get_address('eperson@example.com')) None - >>> print user_manager.get_user('eperson@example.com') + >>> print(user_manager.get_user('eperson@example.com')) None # Clear the virgin queue of all the preceding confirmation messages. @@ -331,7 +331,7 @@ However, the pending event matched with that token will still be removed. >>> token = pendingdb.add(pendable) >>> registrar.confirm(token) False - >>> print pendingdb.confirm(token) + >>> print(pendingdb.confirm(token)) None @@ -346,13 +346,13 @@ list. Before confirmation, Fred is not a member of the mailing list. - >>> print mlist.members.get_member('fred.person@example.com') + >>> print(mlist.members.get_member('fred.person@example.com')) None But after confirmation, he is. >>> registrar.confirm(token) True - >>> print mlist.members.get_member('fred.person@example.com') + >>> print(mlist.members.get_member('fred.person@example.com')) on alpha@example.com as MemberRole.member> diff --git a/src/mailman/model/docs/requests.rst b/src/mailman/model/docs/requests.rst index f911e8fbb..e99cef634 100644 --- a/src/mailman/model/docs/requests.rst +++ b/src/mailman/model/docs/requests.rst @@ -90,17 +90,17 @@ of the request data we want. This returns a 2-tuple of the key and data we originally held. >>> key, data = requests.get_request(2) - >>> print key + >>> print(key) hold_2 There was no additional data associated with request 2. - >>> print data + >>> print(data) None If we ask for a request that is not in the database, we get None back. - >>> print requests.get_request(801) + >>> print(requests.get_request(801)) None @@ -118,7 +118,7 @@ The data is returned when the request is retrieved. The dictionary will have an additional key which holds the name of the request type. >>> key, data = requests.get_request(5) - >>> print key + >>> print(key) hold_5 >>> dump_msgdata(data) _request_type: held_message @@ -136,10 +136,10 @@ over by type. 3 >>> for request in requests.of_type(RequestType.held_message): ... key, data = requests.get_request(request.id) - ... print request.id, request.request_type, key + ... print(request.id, request.request_type, key) ... if data is not None: ... for key in sorted(data): - ... print ' {0}: {1}'.format(key, data[key]) + ... print(' {0}: {1}'.format(key, data[key])) 1 RequestType.held_message hold_1 4 RequestType.held_message hold_4 5 RequestType.held_message hold_5 @@ -162,7 +162,7 @@ database. Request 2 is no longer in the database. - >>> print requests.get_request(2) + >>> print(requests.get_request(2)) None >>> for request in requests.held_requests: diff --git a/src/mailman/model/docs/usermanager.rst b/src/mailman/model/docs/usermanager.rst index cf7672b27..9a8c35c00 100644 --- a/src/mailman/model/docs/usermanager.rst +++ b/src/mailman/model/docs/usermanager.rst @@ -26,14 +26,14 @@ have a password. >>> dump_list(address.email for address in user.addresses) *Empty* - >>> print user.display_name + >>> print(user.display_name) - >>> print user.password + >>> print(user.password) None The user has preferences, but none of them will be specified. - >>> print user.preferences + >>> print(user.preferences) A user can be assigned a real name. @@ -125,10 +125,10 @@ that the ``.get_user()`` method takes a string email address, not an If the address is not in the user database or does not have a user associated with it, you will get ``None`` back. - >>> print user_manager.get_user('zperson@example.com') + >>> print(user_manager.get_user('zperson@example.com')) None >>> user_4.unlink(address) - >>> print user_manager.get_user(address.email) + >>> print(user_manager.get_user(address.email)) None Users can also be found by their unique user id. @@ -144,7 +144,7 @@ Users can also be found by their unique user id. If a non-existent user id is given, None is returned. >>> from uuid import UUID - >>> print user_manager.get_user_by_id(UUID(int=801)) + >>> print(user_manager.get_user_by_id(UUID(int=801))) None @@ -173,8 +173,8 @@ There are now four members in the system. Sort them by address then role. ... return (member.address.email, member.role.name) >>> members = sorted(user_manager.members, key=sort_key) >>> for member in members: - ... print member.mailing_list.list_id, member.address.email, \ - ... member.role + ... print(member.mailing_list.list_id, member.address.email, + ... member.role) test.example.com bperson@example.com MemberRole.member test.example.com bperson@example.com MemberRole.owner test.example.com eperson@example.com MemberRole.member diff --git a/src/mailman/model/docs/users.rst b/src/mailman/model/docs/users.rst index 889fe46d1..2e7333944 100644 --- a/src/mailman/model/docs/users.rst +++ b/src/mailman/model/docs/users.rst @@ -45,14 +45,14 @@ When the user's password is changed, an event is triggered. >>> from mailman.testing.helpers import event_subscribers >>> with event_subscribers(save_event): ... user_1.password = b'changed again' - >>> print saved_event + >>> print(saved_event) The event holds a reference to the `IUser` that changed their password. - >>> print saved_event.user.display_name + >>> print(saved_event.user.display_name) Zoe X. Person - >>> print saved_event.user.password + >>> print(saved_event.user.password) changed again @@ -63,7 +63,7 @@ Although rarely visible to users, every user has a unique ID in Mailman, which never changes. This ID is generated randomly at the time the user is created, and is represented by a UUID. - >>> print user_1.user_id + >>> print(user_1.user_id) 00000000-0000-0000-0000-000000000001 The user id cannot change. @@ -76,7 +76,7 @@ The user id cannot change. User records also have a date on which they where created. # The test suite uses a predictable timestamp. - >>> print user_1.created_on + >>> print(user_1.created_on) 2005-08-01 07:49:23 @@ -138,7 +138,7 @@ that address. True >>> user_manager.get_user('zperson@example.org') is user_1 True - >>> print user_manager.get_user('bperson@example.com') + >>> print(user_manager.get_user('bperson@example.com')) None Addresses can also be unlinked from a user. @@ -146,7 +146,7 @@ Addresses can also be unlinked from a user. >>> user_1.unlink(address_1) >>> user_1.controls('zperson@example.net') False - >>> print user_manager.get_user('aperson@example.net') + >>> print(user_manager.get_user('aperson@example.net')) None But don't try to unlink the address from a user it's not linked to. @@ -173,14 +173,14 @@ change. By default, a user has no preferred address. >>> user_2 = user_manager.create_user() - >>> print user_2.preferred_address + >>> print(user_2.preferred_address) None Even when a user registers an address, this address will not be set as the preferred address. >>> anne = user_2.register('anne@example.com', 'Anne Person') - >>> print user_2.preferred_address + >>> print(user_2.preferred_address) None The preferred address must be explicitly registered, however only verified @@ -233,7 +233,7 @@ A user can disavow their preferred address. >>> user_2.preferred_address >>> del user_2.preferred_address - >>> print user_2.preferred_address + >>> print(user_2.preferred_address) None The preferred address always shows up in the set of addresses controlled by @@ -241,7 +241,7 @@ this user. >>> from operator import attrgetter >>> for address in sorted(user_2.addresses, key=attrgetter('email')): - ... print address.email + ... print(address.email) anne@example.com aperson@example.com @@ -252,11 +252,11 @@ Users and preferences This is a helper function for the following section. >>> def show_prefs(prefs): - ... print 'acknowledge_posts :', prefs.acknowledge_posts - ... print 'preferred_language :', prefs.preferred_language - ... print 'receive_list_copy :', prefs.receive_list_copy - ... print 'receive_own_postings :', prefs.receive_own_postings - ... print 'delivery_mode :', prefs.delivery_mode + ... print('acknowledge_posts :', prefs.acknowledge_posts) + ... print('preferred_language :', prefs.preferred_language) + ... print('receive_list_copy :', prefs.receive_list_copy) + ... print('receive_own_postings :', prefs.receive_own_postings) + ... print('delivery_mode :', prefs.delivery_mode) Users have preferences, but these preferences have no default settings. @@ -334,8 +334,8 @@ membership role. >>> def sortkey(member): ... return member.address.email, member.mailing_list, member.role.value >>> for member in sorted(members, key=sortkey): - ... print member.address.email, member.mailing_list.list_id, \ - ... member.role + ... print(member.address.email, member.mailing_list.list_id, + ... member.role) zperson@example.com xtest_1.example.com MemberRole.member zperson@example.net xtest_3.example.com MemberRole.moderator zperson@example.org xtest_2.example.com MemberRole.member diff --git a/src/mailman/model/tests/test_domain.py b/src/mailman/model/tests/test_domain.py index 0a7ef22f1..f9d1ff202 100644 --- a/src/mailman/model/tests/test_domain.py +++ b/src/mailman/model/tests/test_domain.py @@ -17,7 +17,7 @@ """Test domains.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/model/tests/test_uid.py b/src/mailman/model/tests/test_uid.py index f74ffed54..4c541205a 100644 --- a/src/mailman/model/tests/test_uid.py +++ b/src/mailman/model/tests/test_uid.py @@ -17,7 +17,7 @@ """Test the UID model class.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/model/tests/test_user.py b/src/mailman/model/tests/test_user.py index d184eb176..17d4d24ff 100644 --- a/src/mailman/model/tests/test_user.py +++ b/src/mailman/model/tests/test_user.py @@ -17,7 +17,7 @@ """Test users.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/mta/bulk.py b/src/mailman/mta/bulk.py index da3026083..4255e0c33 100644 --- a/src/mailman/mta/bulk.py +++ b/src/mailman/mta/bulk.py @@ -17,7 +17,7 @@ """Bulk message delivery.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/mta/connection.py b/src/mailman/mta/connection.py index f5c330921..8cf419545 100644 --- a/src/mailman/mta/connection.py +++ b/src/mailman/mta/connection.py @@ -17,7 +17,7 @@ """MTA connections.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/mta/decorating.py b/src/mailman/mta/decorating.py index a23e188a1..ac99b3624 100644 --- a/src/mailman/mta/decorating.py +++ b/src/mailman/mta/decorating.py @@ -17,7 +17,7 @@ """Individualized delivery with header/footer decorations.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/mta/deliver.py b/src/mailman/mta/deliver.py index de6b80a8c..be04a48bd 100644 --- a/src/mailman/mta/deliver.py +++ b/src/mailman/mta/deliver.py @@ -17,7 +17,7 @@ """Generic delivery.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/mta/docs/authentication.rst b/src/mailman/mta/docs/authentication.rst index 9f78859a0..94cd2c99e 100644 --- a/src/mailman/mta/docs/authentication.rst +++ b/src/mailman/mta/docs/authentication.rst @@ -44,7 +44,7 @@ Attempting delivery first must authorize with the mail server. >>> bulk.deliver(mlist, msg, dict(recipients=['bperson@example.com'])) {} - >>> print smtpd.get_authentication_credentials() + >>> print(smtpd.get_authentication_credentials()) PLAIN AHRlc3R1c2VyAHRlc3RwYXNz >>> config.pop('auth') diff --git a/src/mailman/mta/docs/bulk.rst b/src/mailman/mta/docs/bulk.rst index 8bacd4957..f0c4e0132 100644 --- a/src/mailman/mta/docs/bulk.rst +++ b/src/mailman/mta/docs/bulk.rst @@ -95,7 +95,7 @@ a few things. For example, the first two chunks will be composed of ``.net`` 3 >>> for address in sorted(chunks[0].union(chunks[1])): - ... print address + ... print(address) bart@example.org cate@example.net elle@example.org @@ -113,7 +113,7 @@ We also know that the next two chunks will contain ``.com`` (5) addresses. 1 >>> for address in sorted(chunks[2].union(chunks[3])): - ... print address + ... print(address) anne@example.com dave@example.com gwen@example.com @@ -125,7 +125,7 @@ The next chunk will contain the ``.us`` (2) and ``.ca`` (1) domains. >>> len(chunks[4]) 3 >>> for address in sorted(chunks[4]): - ... print address + ... print(address) herb@example.us liam@example.ca mary@example.us @@ -136,7 +136,7 @@ The final chunk will contain the outliers, ``.xx`` (1) and ``.zz`` (2). >>> len(chunks[5]) 2 >>> for address in sorted(chunks[5]): - ... print address + ... print(address) paco@example.xx quaq@example.zz @@ -182,7 +182,7 @@ message sent, with all the recipients packed into the envelope recipients >>> messages = list(smtpd.messages) >>> len(messages) 1 - >>> print messages[0].as_string() + >>> print(messages[0].as_string()) From: aperson@example.org To: test@example.com Subject: test one @@ -212,7 +212,7 @@ each with 20 addresses in the ``RCPT TO``. 5 >>> for message in messages: ... x_rcptto = message['x-rcptto'] - ... print 'Number of recipients:', len(x_rcptto.split(',')) + ... print('Number of recipients:', len(x_rcptto.split(','))) Number of recipients: 20 Number of recipients: 20 Number of recipients: 20 @@ -238,7 +238,7 @@ message metadata... {} >>> message = list(smtpd.messages)[0] - >>> print message.as_string() + >>> print(message.as_string()) From: aperson@example.org To: test@example.com Subject: test one @@ -257,7 +257,7 @@ message metadata... {} >>> message = list(smtpd.messages)[0] - >>> print message.as_string() + >>> print(message.as_string()) From: aperson@example.org To: test@example.com Subject: test one @@ -281,7 +281,7 @@ message. {} >>> message = list(smtpd.messages)[0] - >>> print message.as_string() + >>> print(message.as_string()) From: aperson@example.org To: test@example.com Subject: test one @@ -332,7 +332,7 @@ recipients. >>> failures = bulk.deliver(mlist, msg, msgdata) >>> for address in sorted(failures): - ... print address, failures[address][0], failures[address][1] + ... print(address, failures[address][0], failures[address][1]) aperson@example.org 500 Error: SMTPRecipientsRefused bperson@example.org 500 Error: SMTPRecipientsRefused cperson@example.org 500 Error: SMTPRecipientsRefused @@ -350,7 +350,7 @@ Or there could be some other problem causing an SMTP response failure. >>> failures = bulk.deliver(mlist, msg, msgdata) >>> for address in sorted(failures): - ... print address, failures[address][0], failures[address][1] + ... print(address, failures[address][0], failures[address][1]) aperson@example.org 450 Error: SMTPResponseException bperson@example.org 450 Error: SMTPResponseException cperson@example.org 450 Error: SMTPResponseException @@ -361,7 +361,7 @@ Or there could be some other problem causing an SMTP response failure. >>> failures = bulk.deliver(mlist, msg, msgdata) >>> for address in sorted(failures): - ... print address, failures[address][0], failures[address][1] + ... print(address, failures[address][0], failures[address][1]) aperson@example.org 500 Error: SMTPResponseException bperson@example.org 500 Error: SMTPResponseException cperson@example.org 500 Error: SMTPResponseException diff --git a/src/mailman/mta/docs/connection.rst b/src/mailman/mta/docs/connection.rst index 515a773bd..a57a76bb9 100644 --- a/src/mailman/mta/docs/connection.rst +++ b/src/mailman/mta/docs/connection.rst @@ -69,7 +69,7 @@ will authenticate with the mail server after each new connection. ... ... """) {} - >>> print smtpd.get_authentication_credentials() + >>> print(smtpd.get_authentication_credentials()) PLAIN AHRlc3R1c2VyAHRlc3RwYXNz >>> reset() @@ -243,7 +243,7 @@ about accidental deliveries to unintended recipients. >>> messages = list(smtpd.messages) >>> len(messages) 1 - >>> print messages[0].as_string() + >>> print(messages[0].as_string()) From: anne@example.com To: bart@example.com Subject: aardvarks diff --git a/src/mailman/mta/docs/decorating.rst b/src/mailman/mta/docs/decorating.rst index cf595b0d5..94331163b 100644 --- a/src/mailman/mta/docs/decorating.rst +++ b/src/mailman/mta/docs/decorating.rst @@ -35,17 +35,17 @@ We start by writing the site-global header and footer template. >>> myheader_path = os.path.join(site_dir, 'myheader.txt') >>> with open(myheader_path, 'w') as fp: - ... print >> fp, """\ + ... print("""\ ... Delivery address: $user_address ... Subscribed address: $user_delivered_to - ... """ + ... """, file=fp) >>> myfooter_path = os.path.join(site_dir, 'myfooter.txt') >>> with open(myfooter_path, 'w') as fp: - ... print >> fp, """\ + ... print("""\ ... User name: $user_name ... Language: $user_language ... Options: $user_optionsurl - ... """ + ... """, file=fp) Then create a mailing list which will use this header and footer. Because these are site-global templates, we can use a shorted URL. @@ -108,8 +108,8 @@ The decorations happen when the message is delivered. >>> from operator import itemgetter >>> for message in sorted(messages, key=itemgetter('x-rcptto')): - ... print message.as_string() - ... print '----------' + ... print(message.as_string()) + ... print('----------') From: aperson@example.org To: test@example.com Subject: test one @@ -181,8 +181,8 @@ into the message metadata. 3 >>> for message in sorted(messages, key=itemgetter('x-rcptto')): - ... print message.as_string() - ... print '----------' + ... print(message.as_string()) + ... print('----------') From: aperson@example.org To: test@example.com Subject: test one diff --git a/src/mailman/mta/docs/personalized.rst b/src/mailman/mta/docs/personalized.rst index 6c1c9eb4f..fdd1a35d5 100644 --- a/src/mailman/mta/docs/personalized.rst +++ b/src/mailman/mta/docs/personalized.rst @@ -50,8 +50,8 @@ By default, the ``To:`` header is not personalized. >>> from operator import itemgetter >>> for message in sorted(messages, key=itemgetter('x-rcptto')): - ... print message.as_string() - ... print '----------' + ... print(message.as_string()) + ... print('----------') From: aperson@example.org To: test@example.com Subject: test one @@ -102,8 +102,8 @@ with the recipient's address and name. 3 >>> for message in sorted(messages, key=itemgetter('to')): - ... print message.as_string() - ... print '----------' + ... print(message.as_string()) + ... print('----------') From: aperson@example.org To: aperson@example.com Subject: test one @@ -155,8 +155,8 @@ associated real name, then this name also shows up in the ``To:`` header. >>> from operator import itemgetter >>> for message in sorted(messages, key=itemgetter('x-rcptto')): - ... print message.as_string() - ... print '----------' + ... print(message.as_string()) + ... print('----------') From: aperson@example.org To: aperson@example.com Subject: test one diff --git a/src/mailman/mta/docs/verp.rst b/src/mailman/mta/docs/verp.rst index 2f2f09828..181778dc4 100644 --- a/src/mailman/mta/docs/verp.rst +++ b/src/mailman/mta/docs/verp.rst @@ -84,8 +84,8 @@ VERPing is only actually done if the metadata requests it. >>> from operator import itemgetter >>> for message in sorted(messages, key=itemgetter('x-rcptto')): - ... print message.as_string() - ... print '----------' + ... print(message.as_string()) + ... print('----------') From: aperson@example.org To: test@example.com Subject: test one @@ -119,7 +119,7 @@ VERPing is only actually done if the metadata requests it. The deliverer made a copy of the original message, so it wasn't changed. - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.org To: test@example.com Subject: test one diff --git a/src/mailman/mta/personalized.py b/src/mailman/mta/personalized.py index adc3c90a4..967bca68a 100644 --- a/src/mailman/mta/personalized.py +++ b/src/mailman/mta/personalized.py @@ -17,7 +17,7 @@ """Personalized delivery.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/mta/tests/test_aliases.py b/src/mailman/mta/tests/test_aliases.py index 2c33c7821..30c57e292 100644 --- a/src/mailman/mta/tests/test_aliases.py +++ b/src/mailman/mta/tests/test_aliases.py @@ -17,7 +17,7 @@ """Test the MTA file generating utility.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/mta/verp.py b/src/mailman/mta/verp.py index 968ed58c3..c3d1d0999 100644 --- a/src/mailman/mta/verp.py +++ b/src/mailman/mta/verp.py @@ -17,7 +17,7 @@ """VERP delivery.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/options.py b/src/mailman/options.py index c0b9dea97..a4f553a09 100644 --- a/src/mailman/options.py +++ b/src/mailman/options.py @@ -17,7 +17,7 @@ """Common argument parsing.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/addresses.py b/src/mailman/rest/addresses.py index cb8861a2e..92772d6f3 100644 --- a/src/mailman/rest/addresses.py +++ b/src/mailman/rest/addresses.py @@ -17,7 +17,7 @@ """REST for addresses.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function,unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/docs/__init__.py b/src/mailman/rest/docs/__init__.py index 794f5f034..2daf8a681 100644 --- a/src/mailman/rest/docs/__init__.py +++ b/src/mailman/rest/docs/__init__.py @@ -17,7 +17,7 @@ """Doctest layer setup.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/docs/basic.rst b/src/mailman/rest/docs/basic.rst index cf02fa4ec..51b287c90 100644 --- a/src/mailman/rest/docs/basic.rst +++ b/src/mailman/rest/docs/basic.rst @@ -57,7 +57,7 @@ an appropriate HTTP 401 Unauthorized error. >>> from httplib2 import Http >>> response, content = Http().request(url, 'GET', None, headers) - >>> print content + >>> print(content) 401 Unauthorized User is not authorized for the REST API @@ -69,7 +69,7 @@ But with the right headers, the request succeeds. ... config.webservice.admin_pass)) >>> headers['Authorization'] = 'Basic ' + auth >>> response, content = Http().request(url, 'GET', None, headers) - >>> print response.status + >>> print(response.status) 200 diff --git a/src/mailman/rest/docs/configuration.rst b/src/mailman/rest/docs/configuration.rst index 68644ff88..53ad172e9 100644 --- a/src/mailman/rest/docs/configuration.rst +++ b/src/mailman/rest/docs/configuration.rst @@ -177,7 +177,7 @@ Using ``PATCH``, you can change just one attribute. These values are changed permanently. - >>> print mlist.display_name + >>> print(mlist.display_name) My List @@ -224,7 +224,7 @@ Aliases are returned as a list on the ``aliases`` key. ... 'http://localhost:9001/3.0/lists/' ... 'ant@example.com/config/acceptable_aliases') >>> for alias in response['acceptable_aliases']: - ... print alias + ... print(alias) bar@example.net foo@example.com @@ -233,6 +233,6 @@ The mailing list has its aliases set. >>> from mailman.interfaces.mailinglist import IAcceptableAliasSet >>> aliases = IAcceptableAliasSet(mlist) >>> for alias in sorted(aliases.aliases): - ... print alias + ... print(alias) bar@example.net foo@example.com diff --git a/src/mailman/rest/docs/helpers.rst b/src/mailman/rest/docs/helpers.rst index 3e8092f4e..7405fc98f 100644 --- a/src/mailman/rest/docs/helpers.rst +++ b/src/mailman/rest/docs/helpers.rst @@ -13,7 +13,7 @@ They only need to know where they are relative to the root URI, and this function can return them the full path to the resource. >>> from mailman.rest.helpers import path_to - >>> print path_to('system') + >>> print(path_to('system')) http://localhost:9001/3.0/system Parameters like the ``scheme``, ``host``, ``port``, and API version number can @@ -29,7 +29,7 @@ be set in the configuration file. ... """) >>> cleanups.append((config.pop, 'helpers')) - >>> print path_to('system') + >>> print(path_to('system')) https://geddy:2112/4.2/system @@ -44,7 +44,7 @@ gets modified to contain the etag under the ``http_etag`` key. >>> from mailman.rest.helpers import etag >>> resource = dict(geddy='bass', alex='guitar', neil='drums') >>> json_data = etag(resource) - >>> print resource['http_etag'] + >>> print(resource['http_etag']) "43942176d8d5bb4414ccf35e2720ccd5251e66da" For convenience, the etag function also returns the JSON representation of the @@ -79,7 +79,7 @@ their values. On valid input, the validator can be used as a ``**keyword`` argument. >>> def print_request(one, two, three): - ... print repr(one), repr(two), repr(three) + ... print(repr(one), repr(two), repr(three)) >>> print_request(**validator(FakeRequest)) 1 u'two' True @@ -126,7 +126,7 @@ However, if optional keys are missing, it's okay. >>> FakeRequest.POST = dict(one='1', two='two', three='yes', ... four='4', five='5') >>> def print_request(one, two, three, four=None, five=None): - ... print repr(one), repr(two), repr(three), repr(four), repr(five) + ... print(repr(one), repr(two), repr(three), repr(four), repr(five)) >>> print_request(**validator(FakeRequest)) 1 u'two' True 4 5 @@ -183,9 +183,9 @@ And a validator to pull it all together. >>> validator = Validator(one=must_be_scalar, many=must_be_list) >>> FakeRequest.POST = form_data >>> values = validator(FakeRequest) - >>> print values['one'] + >>> print(values['one']) 1 - >>> print values['many'] + >>> print(values['many']) [3, 4, 5] The list values are guaranteed to be in the same order they show up in the @@ -197,7 +197,7 @@ form data. >>> form_data.add('many', '4') >>> FakeRequest.POST = form_data >>> values = validator(FakeRequest) - >>> print values['one'] + >>> print(values['one']) 1 - >>> print values['many'] + >>> print(values['many']) [3, 5, 4] diff --git a/src/mailman/rest/docs/lists.rst b/src/mailman/rest/docs/lists.rst index 27503c1c1..aa03de039 100644 --- a/src/mailman/rest/docs/lists.rst +++ b/src/mailman/rest/docs/lists.rst @@ -210,7 +210,7 @@ Existing mailing lists can be deleted through the API, by doing an HTTP The mailing list does not exist. - >>> print list_manager.get('bee@example.com') + >>> print(list_manager.get('bee@example.com')) None .. Abort the Storm transaction. @@ -228,7 +228,7 @@ address as well. The mailing list does not exist. - >>> print list_manager.get('ant@example.com') + >>> print(list_manager.get('ant@example.com')) None diff --git a/src/mailman/rest/docs/membership.rst b/src/mailman/rest/docs/membership.rst index 7c92d8343..30e69d9f5 100644 --- a/src/mailman/rest/docs/membership.rst +++ b/src/mailman/rest/docs/membership.rst @@ -706,7 +706,7 @@ Fred is getting MIME deliveries. >>> memberships[0] on ant@example.com as MemberRole.member> - >>> print memberships[0].delivery_mode + >>> print(memberships[0].delivery_mode) DeliveryMode.mime_digests >>> dump_json('http://localhost:9001/3.0/members/10') @@ -825,7 +825,7 @@ Herb must iterate through his memberships explicitly. ... 'herb@example.com/memberships') >>> memberships = [entry['self_link'] for entry in content['entries']] >>> for url in sorted(memberships): - ... print url + ... print(url) http://localhost:9001/3.0/members/11 http://localhost:9001/3.0/members/12 diff --git a/src/mailman/rest/docs/moderation.rst b/src/mailman/rest/docs/moderation.rst index 1b08b8d06..44182eb23 100644 --- a/src/mailman/rest/docs/moderation.rst +++ b/src/mailman/rest/docs/moderation.rst @@ -158,7 +158,7 @@ moderation. >>> transaction.commit() >>> results = call_http(url(request_id)) - >>> print results['message_id'] + >>> print(results['message_id']) >>> dump_json(url(request_id), { @@ -173,7 +173,7 @@ moderation. >>> messages = get_queue_messages('pipeline') >>> len(messages) 1 - >>> print messages[0].msg['message-id'] + >>> print(messages[0].msg['message-id']) Messages can be rejected via the REST API too. These bounce the message back @@ -186,7 +186,7 @@ to the original author. >>> transaction.commit() >>> results = call_http(url(request_id)) - >>> print results['message_id'] + >>> print(results['message_id']) >>> dump_json(url(request_id), { @@ -201,7 +201,7 @@ to the original author. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg['subject'] + >>> print(messages[0].msg['subject']) Request to mailing list "Ant" rejected @@ -358,7 +358,7 @@ Bart's unsubscription request is discarded. Bart is still a member of the mailing list. >>> transaction.abort() - >>> print ant.members.get_member('bart@example.com') + >>> print(ant.members.get_member('bart@example.com')) on ant@example.com as MemberRole.member> >>> transaction.abort() diff --git a/src/mailman/rest/domains.py b/src/mailman/rest/domains.py index e9ef8e055..1a260ea3d 100644 --- a/src/mailman/rest/domains.py +++ b/src/mailman/rest/domains.py @@ -17,7 +17,7 @@ """REST for domains.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/helpers.py b/src/mailman/rest/helpers.py index d05dedd90..025ad1779 100644 --- a/src/mailman/rest/helpers.py +++ b/src/mailman/rest/helpers.py @@ -17,7 +17,7 @@ """Web service helpers.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/lists.py b/src/mailman/rest/lists.py index 066b6618f..552824927 100644 --- a/src/mailman/rest/lists.py +++ b/src/mailman/rest/lists.py @@ -17,7 +17,7 @@ """REST for mailing lists.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/members.py b/src/mailman/rest/members.py index 4aef93e34..51cbbd888 100644 --- a/src/mailman/rest/members.py +++ b/src/mailman/rest/members.py @@ -17,7 +17,7 @@ """REST for members.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/preferences.py b/src/mailman/rest/preferences.py index 0789d39c4..bbc6b1769 100644 --- a/src/mailman/rest/preferences.py +++ b/src/mailman/rest/preferences.py @@ -17,7 +17,7 @@ """Preferences.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/root.py b/src/mailman/rest/root.py index f1f99daec..ec0c9c93b 100644 --- a/src/mailman/rest/root.py +++ b/src/mailman/rest/root.py @@ -17,7 +17,7 @@ """The root of the REST API.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/tests/test_root.py b/src/mailman/rest/tests/test_root.py index 96a41edf7..42ea2f6f9 100644 --- a/src/mailman/rest/tests/test_root.py +++ b/src/mailman/rest/tests/test_root.py @@ -17,7 +17,7 @@ """REST root object tests.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/users.py b/src/mailman/rest/users.py index 731e7e5d3..bf9668564 100644 --- a/src/mailman/rest/users.py +++ b/src/mailman/rest/users.py @@ -17,7 +17,7 @@ """REST for users.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rest/validator.py b/src/mailman/rest/validator.py index 72695d551..90d0334e9 100644 --- a/src/mailman/rest/validator.py +++ b/src/mailman/rest/validator.py @@ -17,7 +17,7 @@ """REST web form validation.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/rules/docs/administrivia.rst b/src/mailman/rules/docs/administrivia.rst index bfc5efdcc..679d7aad8 100644 --- a/src/mailman/rules/docs/administrivia.rst +++ b/src/mailman/rules/docs/administrivia.rst @@ -10,7 +10,7 @@ the ``-request`` robot address. >>> mlist = create_list('_xtest@example.com') >>> mlist.administrivia = True >>> rule = config.rules['administrivia'] - >>> print rule.name + >>> print(rule.name) administrivia For example, if the ``Subject:`` header contains the word ``unsubscribe``, the diff --git a/src/mailman/rules/docs/approved.rst b/src/mailman/rules/docs/approved.rst index 3f3d54455..2e49e0458 100644 --- a/src/mailman/rules/docs/approved.rst +++ b/src/mailman/rules/docs/approved.rst @@ -27,7 +27,7 @@ The ``approved`` rule determines whether the message contains the proper approval or not. >>> rule = config.rules['approved'] - >>> print rule.name + >>> print(rule.name) approved @@ -102,7 +102,7 @@ the ``Approved`` header (LP: #973790) when it matches. >>> msg['Approved'] = 'super secret' >>> rule.check(mlist, msg, {}) True - >>> print msg['approved'] + >>> print(msg['approved']) None It also removes the header when it doesn't match. If the rule didn't do this, @@ -111,7 +111,7 @@ then the mailing list could be probed for its moderator password. >>> msg['Approved'] = 'not the password' >>> rule.check(mlist, msg, {}) False - >>> print msg['approved'] + >>> print(msg['approved']) None @@ -135,7 +135,7 @@ payload of the message. If this pseudo-header looks like a matching The pseudo-header is always removed from the body of plain text messages. - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Content-Transfer-Encoding: 7bit MIME-Version: 1.0 @@ -157,7 +157,7 @@ the pseudo-header line is still removed. >>> rule.check(mlist, msg, {}) False - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com Content-Transfer-Encoding: 7bit MIME-Version: 1.0 @@ -197,7 +197,7 @@ be used with MIME documents. Like before, the pseudo-header is removed, but only from the text parts. - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="AAA" @@ -242,7 +242,7 @@ If the correct password is in the non-``text/plain`` part, it is ignored. Pseudo-header is still stripped, but only from the ``text/plain`` part. - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="AAA" @@ -297,7 +297,7 @@ anything that looks like an ``Approved:`` header. And the header-like text in the ``text/html`` part was stripped. - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="AAA" @@ -354,7 +354,7 @@ given). >>> rule.check(mlist, msg, {}) False - >>> print msg.as_string() + >>> print(msg.as_string()) From: aperson@example.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="AAA" diff --git a/src/mailman/rules/docs/header-matching.rst b/src/mailman/rules/docs/header-matching.rst index 20e55fadd..3c175e6e1 100644 --- a/src/mailman/rules/docs/header-matching.rst +++ b/src/mailman/rules/docs/header-matching.rst @@ -34,20 +34,20 @@ through the chain with no matches. >>> def hits_and_misses(msgdata): ... hits = msgdata.get('rule_hits', []) ... if len(hits) == 0: - ... print 'No rules hit' + ... print('No rules hit') ... else: - ... print 'Rule hits:' + ... print('Rule hits:') ... for rule_name in hits: ... rule = config.rules[rule_name] - ... print ' {0}: {1}'.format(rule.header, rule.pattern) + ... print(' {0}: {1}'.format(rule.header, rule.pattern)) ... misses = msgdata.get('rule_misses', []) ... if len(misses) == 0: - ... print 'No rules missed' + ... print('No rules missed') ... else: - ... print 'Rule misses:' + ... print('Rule misses:') ... for rule_name in misses: ... rule = config.rules[rule_name] - ... print ' {0}: {1}'.format(rule.header, rule.pattern) + ... print(' {0}: {1}'.format(rule.header, rule.pattern)) By looking at the message metadata after chain processing, we can see that none of the rules matched. @@ -78,8 +78,8 @@ matches, it gets held for moderator approval. >>> from mailman.testing.helpers import event_subscribers >>> def handler(event): ... if isinstance(event, ChainEvent): - ... print event.__class__.__name__, \ - ... event.chain.name, event.msg['message-id'] + ... print(event.__class__.__name__, + ... event.chain.name, event.msg['message-id']) >>> del msg['x-spam-score'] >>> msg['X-Spam-Score'] = '*****' diff --git a/src/mailman/rules/docs/implicit-dest.rst b/src/mailman/rules/docs/implicit-dest.rst index b0464d0a5..89d2459b0 100644 --- a/src/mailman/rules/docs/implicit-dest.rst +++ b/src/mailman/rules/docs/implicit-dest.rst @@ -7,7 +7,7 @@ not explicitly mentioned in the set of message recipients. >>> mlist = create_list('_xtest@example.com') >>> rule = config.rules['implicit-dest'] - >>> print rule.name + >>> print(rule.name) implicit-dest In order to check for implicit destinations, we need to adapt the mailing list diff --git a/src/mailman/rules/docs/loop.rst b/src/mailman/rules/docs/loop.rst index 716029065..3b267f0ee 100644 --- a/src/mailman/rules/docs/loop.rst +++ b/src/mailman/rules/docs/loop.rst @@ -7,7 +7,7 @@ RFC 2369 ``List-Post:`` header with the value of the list's posting address. >>> mlist = create_list('_xtest@example.com') >>> rule = config.rules['loop'] - >>> print rule.name + >>> print(rule.name) loop The header could be missing, in which case the rule does not match. diff --git a/src/mailman/rules/docs/max-size.rst b/src/mailman/rules/docs/max-size.rst index 87856f0f1..b792202cb 100644 --- a/src/mailman/rules/docs/max-size.rst +++ b/src/mailman/rules/docs/max-size.rst @@ -9,7 +9,7 @@ bytes). >>> mlist = create_list('_xtest@example.com') >>> rule = config.rules['max-size'] - >>> print rule.name + >>> print(rule.name) max-size For example, setting the maximum message size to 1 means that any message diff --git a/src/mailman/rules/docs/moderation.rst b/src/mailman/rules/docs/moderation.rst index 3000f23a2..5631c882d 100644 --- a/src/mailman/rules/docs/moderation.rst +++ b/src/mailman/rules/docs/moderation.rst @@ -17,7 +17,7 @@ Member moderation ================= >>> member_rule = config.rules['member-moderation'] - >>> print member_rule.name + >>> print(member_rule.name) member-moderation Anne, a mailing list member, sends a message to the mailing list. Her @@ -27,7 +27,7 @@ postings are not moderated. >>> from mailman.testing.helpers import subscribe >>> subscribe(mlist, 'Anne') >>> member = mlist.members.get_member('aperson@example.com') - >>> print member.moderation_action + >>> print(member.moderation_action) Action.defer Because Anne is not moderated, the member moderation rule does not match. @@ -62,7 +62,7 @@ Nonmembers are handled in a similar way, although by default, nonmember postings are held for moderator approval. >>> nonmember_rule = config.rules['nonmember-moderation'] - >>> print nonmember_rule.name + >>> print(nonmember_rule.name) nonmember-moderation Bart, who is not a member of the mailing list, sends a message to the list. @@ -70,7 +70,7 @@ Bart, who is not a member of the mailing list, sends a message to the list. >>> from mailman.interfaces.member import MemberRole >>> subscribe(mlist, 'Bart', MemberRole.nonmember) >>> nonmember = mlist.nonmembers.get_member('bperson@example.com') - >>> print nonmember.moderation_action + >>> print(nonmember.moderation_action) Action.hold When Bart is registered as a nonmember of the list, his moderation action is diff --git a/src/mailman/rules/docs/news-moderation.rst b/src/mailman/rules/docs/news-moderation.rst index 0400c8d9f..b77bc4dc1 100644 --- a/src/mailman/rules/docs/news-moderation.rst +++ b/src/mailman/rules/docs/news-moderation.rst @@ -11,7 +11,7 @@ directly to the mailing list. >>> mlist = create_list('_xtest@example.com') >>> rule = config.rules['news-moderation'] - >>> print rule.name + >>> print(rule.name) news-moderation Set the list configuration variable to enable newsgroup moderation. diff --git a/src/mailman/rules/docs/no-subject.rst b/src/mailman/rules/docs/no-subject.rst index 4876bc82c..5166100e2 100644 --- a/src/mailman/rules/docs/no-subject.rst +++ b/src/mailman/rules/docs/no-subject.rst @@ -7,7 +7,7 @@ is the empty string when stripped. >>> mlist = create_list('_xtest@example.com') >>> rule = config.rules['no-subject'] - >>> print rule.name + >>> print(rule.name) no-subject A message with a non-empty subject does not match the rule. diff --git a/src/mailman/rules/docs/recipients.rst b/src/mailman/rules/docs/recipients.rst index aabf397a5..fa0d5be55 100644 --- a/src/mailman/rules/docs/recipients.rst +++ b/src/mailman/rules/docs/recipients.rst @@ -7,7 +7,7 @@ explicit recipients addressed by the message. >>> mlist = create_list('_xtest@example.com') >>> rule = config.rules['max-recipients'] - >>> print rule.name + >>> print(rule.name) max-recipients In this case, we'll create a message with five recipients. These include all diff --git a/src/mailman/rules/docs/rules.rst b/src/mailman/rules/docs/rules.rst index 3c2eab04d..e2ff747b9 100644 --- a/src/mailman/rules/docs/rules.rst +++ b/src/mailman/rules/docs/rules.rst @@ -17,7 +17,7 @@ names to rule objects. >>> from mailman.interfaces.rules import IRule >>> for rule_name in sorted(config.rules): ... rule = config.rules[rule_name] - ... print rule_name, verifyObject(IRule, rule) + ... print(rule_name, verifyObject(IRule, rule)) administrivia True any True approved True @@ -58,7 +58,7 @@ For example, the ``emergency`` rule just checks to see if the emergency flag is set on the mailing list, and the message has not been pre-approved by the list administrator. - >>> print rule.name + >>> print(rule.name) emergency >>> mlist.emergency = False >>> rule.check(mlist, msg, {}) diff --git a/src/mailman/rules/docs/suspicious.rst b/src/mailman/rules/docs/suspicious.rst index 9eb8ae7ae..213af5384 100644 --- a/src/mailman/rules/docs/suspicious.rst +++ b/src/mailman/rules/docs/suspicious.rst @@ -8,7 +8,7 @@ confusing to users, and the list attribute that controls this is misnamed. >>> mlist = create_list('_xtest@example.com') >>> rule = config.rules['suspicious-header'] - >>> print rule.name + >>> print(rule.name) suspicious-header Set the so-called suspicious header configuration variable. diff --git a/src/mailman/runners/digest.py b/src/mailman/runners/digest.py index b48dfba13..f2c888275 100644 --- a/src/mailman/runners/digest.py +++ b/src/mailman/runners/digest.py @@ -17,7 +17,7 @@ """Digest runner.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ @@ -95,7 +95,7 @@ class Digester: mlist.fqdn_listname, mlist.digest_header_uri)) self._header = '' self._toc = StringIO() - print >> self._toc, _("Today's Topics:\n") + print(_("Today's Topics:\n"), file=self._toc) def add_to_toc(self, msg, count): """Add a message to the table of contents.""" @@ -127,10 +127,10 @@ class Digester: first = True for line in lines: if first: - print >> self._toc, ' ', line + print(' ', line, file=self._toc) first = False else: - print >> self._toc, ' ', line.lstrip() + print(' ', line.lstrip(), file=self._toc) def add_message(self, msg, count): """Add the message to the digest.""" @@ -225,12 +225,12 @@ class RFC1153Digester(Digester): self._separator70 = '-' * 70 self._separator30 = '-' * 30 self._text = StringIO() - print >> self._text, self._masthead - print >> self._text + print(self._masthead, file=self._text) + print(file=self._text) # Add the optional digest header. if mlist.digest_header_uri is not None: - print >> self._text, self._header - print >> self._text + print(self._header, file=self._text) + print(file=self._text) # Calculate the set of headers we're to keep in the RFC1153 digest. self._keepers = set(config.digests.plain_digest_keep_headers.split()) @@ -239,24 +239,24 @@ class RFC1153Digester(Digester): def add_toc(self, count): """Add the table of contents.""" - print >> self._text, self._toc.getvalue() - print >> self._text - print >> self._text, self._separator70 - print >> self._text + print(self._toc.getvalue(), file=self._text) + print(file=self._text) + print(self._separator70, file=self._text) + print(file=self._text) def add_message(self, msg, count): """Add the message to the digest.""" if count > 1: - print >> self._text, self._separator30 - print >> self._text + print(self._separator30, file=self._text) + print(file=self._text) # Each message section contains a few headers. for header in config.digests.plain_digest_keep_headers.split(): if header in msg: value = oneline(msg[header], in_unicode=True) value = wrap('{0}: {1}'.format(header, value)) value = '\n\t'.join(value.split('\n')) - print >> self._text, value - print >> self._text + print(value, file=self._text) + print(file=self._text) # Add the payload. If the decoded payload is empty, this may be a # multipart message. In that case, just stringify it. payload = msg.get_payload(decode=True) @@ -267,9 +267,9 @@ class RFC1153Digester(Digester): except (LookupError, TypeError): # Unknown or empty charset. payload = unicode(payload, 'us-ascii', 'replace') - print >> self._text, payload + print(payload, file=self._text) if not payload.endswith('\n'): - print >> self._text + print(file=self._text) def finish(self): """Finish up the digest, producing the email-ready copy.""" @@ -286,18 +286,18 @@ class RFC1153Digester(Digester): # MAS: There is no real place for the digest_footer in an RFC 1153 # compliant digest, so add it as an additional message with # Subject: Digest Footer - print >> self._text, self._separator30 - print >> self._text - print >> self._text, 'Subject: ' + _('Digest Footer') - print >> self._text - print >> self._text, footer_text - print >> self._text - print >> self._text, self._separator30 - print >> self._text + print(self._separator30, file=self._text) + print(file=self._text) + print('Subject: ' + _('Digest Footer'), file=self._text) + print(file=self._text) + print(footer_text, file=self._text) + print(file=self._text) + print(self._separator30, file=self._text) + print(file=self._text) # Add the sign-off. sign_off = _('End of ') + self._digest_id - print >> self._text, sign_off - print >> self._text, '*' * len(sign_off) + print(sign_off, file=self._text) + print('*' * len(sign_off), file=self._text) # If the digest message can't be encoded by the list character set, # fall back to utf-8. text = self._text.getvalue() @@ -325,7 +325,7 @@ class DigestRunner(Runner): rfc1153_digest = RFC1153Digester(mlist, volume, digest_number) # Cruise through all the messages in the mailbox, first building # the table of contents and accumulating Subject: headers and - # authors. The question really is whether it's better from a + # authors. The question really is whether it's better from a1 # performance and memory footprint to go through the mailbox once # and cache the messages in a list, or to cruise through the # mailbox twice. We'll do the latter, but it's a complete guess. diff --git a/src/mailman/runners/docs/command.rst b/src/mailman/runners/docs/command.rst index 43682056b..a7a4da8ed 100644 --- a/src/mailman/runners/docs/command.rst +++ b/src/mailman/runners/docs/command.rst @@ -41,7 +41,7 @@ And now the response is in the ``virgin`` queue. >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) Subject: The results of your email commands From: test-bounces@example.com To: aperson@example.com @@ -91,7 +91,7 @@ message is plain text. >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) Subject: The results of your email commands From: test-bounces@example.com To: bperson@example.com @@ -144,7 +144,7 @@ address, and the other is the results of his email command. >>> registrar = getUtility(IRegistrar) >>> for item in messages: ... subject = item.msg['subject'] - ... print 'Subject:', subject + ... print('Subject:', subject) ... if 'confirm' in str(subject): ... token = str(subject).split()[1].strip() ... status = registrar.confirm(token) @@ -171,7 +171,7 @@ Similarly, to leave a mailing list, the user need only email the ``-leave`` or >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) Subject: The results of your email commands From: test-bounces@example.com To: dperson@example.com @@ -206,7 +206,7 @@ The ``-confirm`` address is also available as an implicit command. >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) Subject: The results of your email commands From: test-bounces@example.com To: dperson@example.com @@ -250,7 +250,7 @@ looked at by the command queue. >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) Subject: The results of your email commands ... @@ -282,7 +282,7 @@ The ``stop`` command is an alias for ``end``. >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) Subject: The results of your email commands ... diff --git a/src/mailman/runners/docs/digester.rst b/src/mailman/runners/docs/digester.rst index 96e8739e3..cd0fba67c 100644 --- a/src/mailman/runners/docs/digester.rst +++ b/src/mailman/runners/docs/digester.rst @@ -48,7 +48,7 @@ messages to put in the digest. The marker message is empty. - >>> print entry.msg.as_string() + >>> print(entry.msg.as_string()) But the message metadata has a reference to the digest file. :: @@ -97,7 +97,7 @@ The MIME digest is a multipart, and the RFC 1153 digest is the other one. The MIME digest has lots of good stuff, all contained in the multipart. - >>> print mime.msg.as_string() + >>> print(mime.msg.as_string()) Content-Type: multipart/mixed; boundary="===============...==" MIME-Version: 1.0 From: test-request@example.com @@ -199,7 +199,7 @@ The MIME digest has lots of good stuff, all contained in the multipart. The RFC 1153 contains the digest in a single plain text message. - >>> print rfc1153.msg.as_string() + >>> print(rfc1153.msg.as_string()) From: test-request@example.com Subject: Test Digest, Vol 1, Issue 1 To: test@example.com @@ -342,7 +342,7 @@ One of which is the MIME digest and the other of which is the RFC 1153 digest. You can see that the digests contain a mix of French and Japanese. - >>> print mime.msg.as_string() + >>> print(mime.msg.as_string()) Content-Type: multipart/mixed; boundary="===============...==" MIME-Version: 1.0 From: test-request@example.com @@ -411,7 +411,7 @@ You can see that the digests contain a mix of French and Japanese. The RFC 1153 digest will be encoded in UTF-8 since it contains a mixture of French and Japanese characters. - >>> print rfc1153.msg.as_string() + >>> print(rfc1153.msg.as_string()) From: test-request@example.com Subject: Groupe Test, Vol 1, Parution 2 To: test@example.com diff --git a/src/mailman/runners/docs/incoming.rst b/src/mailman/runners/docs/incoming.rst index 8830031e6..0ae3336ca 100644 --- a/src/mailman/runners/docs/incoming.rst +++ b/src/mailman/runners/docs/incoming.rst @@ -12,7 +12,7 @@ posted to the mailing list. This chain is processed with the message eventually ending up in one of the four disposition states described above. >>> mlist = create_list('test@example.com') - >>> print mlist.posting_chain + >>> print(mlist.posting_chain) default-posting-chain @@ -43,11 +43,11 @@ While configurable, the *sender addresses* by default are those named in the >>> from zope.component import getUtility >>> from mailman.interfaces.usermanager import IUserManager >>> user_manager = getUtility(IUserManager) - >>> print user_manager.get_address('xperson@example.com') + >>> print(user_manager.get_address('xperson@example.com')) None - >>> print user_manager.get_address('yperson@example.com') + >>> print(user_manager.get_address('yperson@example.com')) None - >>> print user_manager.get_address('zperson@example.com') + >>> print(user_manager.get_address('zperson@example.com')) None Inject the message into the incoming queue, similar to the way the upstream @@ -69,10 +69,10 @@ not linked to a user and are unverified. >>> for localpart in ('xperson', 'yperson', 'zperson'): ... email = '{0}@example.com'.format(localpart) ... address = user_manager.get_address(email) - ... print '{0}; verified? {1}; user? {2}'.format( - ... address.email, - ... ('No' if address.verified_on is None else 'Yes'), - ... user_manager.get_user(email)) + ... print('{0}; verified? {1}; user? {2}'.format( + ... address.email, + ... ('No' if address.verified_on is None else 'Yes'), + ... user_manager.get_user(email))) xperson@example.com; verified? No; user? None yperson@example.com; verified? No; user? None zperson@example.com; verified? No; user? None @@ -116,7 +116,7 @@ Now the message is in the pipeline queue. >>> messages = get_queue_messages('pipeline') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) From: aperson@example.com To: test@example.com Subject: My first post @@ -146,11 +146,11 @@ pipeline queue. >>> from mailman.interfaces.chain import ChainEvent >>> def on_chain(event): ... if isinstance(event, ChainEvent): - ... print event - ... print event.chain - ... print 'From: {0}\nTo: {1}\nMessage-ID: {2}'.format( + ... print(event) + ... print(event.chain) + ... print('From: {0}\nTo: {1}\nMessage-ID: {2}'.format( ... event.msg['from'], event.msg['to'], - ... event.msg['message-id']) + ... event.msg['message-id'])) >>> mlist.emergency = True @@ -234,7 +234,7 @@ to the original sender. >>> messages = get_queue_messages('virgin') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) Subject: My first post From: test-owner@example.com To: aperson@example.com diff --git a/src/mailman/runners/docs/lmtp.rst b/src/mailman/runners/docs/lmtp.rst index 3ce145907..c2227581f 100644 --- a/src/mailman/runners/docs/lmtp.rst +++ b/src/mailman/runners/docs/lmtp.rst @@ -71,7 +71,7 @@ queue. >>> messages = get_queue_messages('in') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) From: anne.person@example.com To: mylist@example.com Subject: An interesting message @@ -134,7 +134,7 @@ command queue for processing. >>> messages = get_queue_messages('command') >>> len(messages) 1 - >>> print messages[0].msg.as_string() + >>> print(messages[0].msg.as_string()) From: anne.person@example.com To: mylist-request@example.com Subject: Help diff --git a/src/mailman/runners/docs/nntp.rst b/src/mailman/runners/docs/nntp.rst index 31c7210cf..372fa5744 100644 --- a/src/mailman/runners/docs/nntp.rst +++ b/src/mailman/runners/docs/nntp.rst @@ -45,7 +45,7 @@ The message gets copied to the NNTP queue for preparation and posting. The message was successfully posted the NNTP server. - >>> print nntpd.get_message().as_string() + >>> print(nntpd.get_message().as_string()) From: aperson@example.com To: test@example.com Newsgroups: comp.lang.python diff --git a/src/mailman/runners/docs/outgoing.rst b/src/mailman/runners/docs/outgoing.rst index d8963ae00..a3220e423 100644 --- a/src/mailman/runners/docs/outgoing.rst +++ b/src/mailman/runners/docs/outgoing.rst @@ -74,7 +74,7 @@ Every recipient got the same copy of the message. >>> len(messages) 1 - >>> print messages[0].as_string() + >>> print(messages[0].as_string()) From: aperson@example.com To: test@example.com Subject: My first post @@ -119,7 +119,7 @@ recipients. >>> from operator import itemgetter >>> def show_headers(messages): ... for message in sorted(messages, key=itemgetter('x-rcptto')): - ... print message['X-RcptTo'], message['X-MailFrom'] + ... print(message['X-RcptTo'], message['X-MailFrom']) >>> show_headers(messages) aperson@example.com test-bounces@example.com diff --git a/src/mailman/runners/rest.py b/src/mailman/runners/rest.py index fb21bf534..5980e6263 100644 --- a/src/mailman/runners/rest.py +++ b/src/mailman/runners/rest.py @@ -17,7 +17,7 @@ """Start the administrative HTTP server.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/runners/retry.py b/src/mailman/runners/retry.py index 41220b989..b4148ee3a 100644 --- a/src/mailman/runners/retry.py +++ b/src/mailman/runners/retry.py @@ -17,7 +17,7 @@ """Retry delivery.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/runners/tests/test_outgoing.py b/src/mailman/runners/tests/test_outgoing.py index feff2799a..62f6776b1 100644 --- a/src/mailman/runners/tests/test_outgoing.py +++ b/src/mailman/runners/tests/test_outgoing.py @@ -17,7 +17,7 @@ """Test the outgoing runner.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/runners/tests/test_retry.py b/src/mailman/runners/tests/test_retry.py index e4f021e45..28289bc05 100644 --- a/src/mailman/runners/tests/test_retry.py +++ b/src/mailman/runners/tests/test_retry.py @@ -17,7 +17,7 @@ """Test the retry runner.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/styles/docs/styles.rst b/src/mailman/styles/docs/styles.rst index 00d95b08d..270b0cdcc 100644 --- a/src/mailman/styles/docs/styles.rst +++ b/src/mailman/styles/docs/styles.rst @@ -20,7 +20,7 @@ To start with, there are a few legacy styles. >>> from mailman.interfaces.styles import IStyleManager >>> manager = getUtility(IStyleManager) >>> for style in manager.styles: - ... print style.name + ... print(style.name) legacy-announce legacy-default @@ -29,13 +29,13 @@ style is applied. >>> from mailman.interfaces.listmanager import IListManager >>> mlist = getUtility(IListManager).create('ant@example.com') - >>> print mlist.display_name + >>> print(mlist.display_name) None The legacy default style sets the list's display name. >>> manager.get('legacy-default').apply(mlist) - >>> print mlist.display_name + >>> print(mlist.display_name) Ant @@ -60,7 +60,7 @@ You can register a new style with the style manager. All registered styles are returned in alphabetical order by style name. >>> for style in manager.styles: - ... print style.name + ... print(style.name) a-test-style legacy-announce legacy-default @@ -68,7 +68,7 @@ All registered styles are returned in alphabetical order by style name. You can also ask the style manager for the style, by name. >>> test_style = manager.get('a-test-style') - >>> print test_style.name + >>> print(test_style.name) a-test-style @@ -79,13 +79,13 @@ You can unregister a style, making it unavailable in the future. >>> manager.unregister(test_style) >>> for style in manager.styles: - ... print style.name + ... print(style.name) legacy-announce legacy-default Asking for a missing style returns None. - >>> print manager.get('a-test-style') + >>> print(manager.get('a-test-style')) None @@ -106,7 +106,7 @@ Now, when we use the high level API, we can ask for the style to be applied. The style has been applied. - >>> print mlist.display_name + >>> print(mlist.display_name) TEST STYLE LIST If no style name is provided when creating the list, the system default style @@ -127,5 +127,5 @@ other style is explicitly given. >>> with configuration('styles', default=another_style.name): ... manager.register(another_style) ... mlist = create_list('cat@example.com') - >>> print mlist.display_name + >>> print(mlist.display_name) ANOTHER STYLE LIST diff --git a/src/mailman/testing/documentation.py b/src/mailman/testing/documentation.py index d204a008f..b8d852fed 100644 --- a/src/mailman/testing/documentation.py +++ b/src/mailman/testing/documentation.py @@ -21,7 +21,7 @@ Note that doctest extraction does not currently work for zip file distributions. doctest discovery currently requires file system traversal. """ -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ @@ -54,7 +54,7 @@ def stop(): def dump_msgdata(msgdata, *additional_skips): """Dump in a more readable way a message metadata dictionary.""" if len(msgdata) == 0: - print '*Empty*' + print('*Empty*') return skips = set(additional_skips) # Some stuff we always want to skip, because their values will always be @@ -64,7 +64,7 @@ def dump_msgdata(msgdata, *additional_skips): for key in sorted(msgdata): if key in skips: continue - print '{0:{2}}: {1}'.format(key, msgdata[key], longest) + print('{0:{2}}: {1}'.format(key, msgdata[key], longest)) def dump_list(list_of_things, key=str): @@ -72,11 +72,11 @@ def dump_list(list_of_things, key=str): # List of things may be a generator. list_of_things = list(list_of_things) if len(list_of_things) == 0: - print '*Empty*' + print('*Empty*') if key is not None: list_of_things = sorted(list_of_things, key=key) for item in list_of_things: - print item + print(item) def call_http(url, data=None, method=None, username=None, password=None): @@ -102,7 +102,7 @@ def call_http(url, data=None, method=None, username=None, password=None): content, response = call_api(url, data, method, username, password) if content is None: for header in sorted(response): - print '{0}: {1}'.format(header, response[header]) + print('{0}: {1}'.format(header, response[header])) return None return content @@ -131,15 +131,15 @@ def dump_json(url, data=None, method=None, username=None, password=None): if key == 'entries': for i, entry in enumerate(value): # entry is a dictionary. - print 'entry %d:' % i + print('entry %d:' % i) for entry_key in sorted(entry): - print ' {0}: {1}'.format(entry_key, entry[entry_key]) + print(' {0}: {1}'.format(entry_key, entry[entry_key])) elif isinstance(value, list): printable_value = COMMASPACE.join( "'{0}'".format(s) for s in sorted(value)) - print '{0}: [{1}]'.format(key, printable_value) + print('{0}: [{1}]'.format(key, printable_value)) else: - print '{0}: {1}'.format(key, value) + print('{0}: {1}'.format(key, value)) @@ -148,6 +148,7 @@ def setup(testobj): # Make sure future statements in our doctests are the same as everywhere # else. testobj.globs['absolute_import'] = absolute_import + testobj.globs['print_function'] = print_function testobj.globs['unicode_literals'] = unicode_literals # In general, I don't like adding convenience functions, since I think # doctests should do the imports themselves. It makes for better diff --git a/src/mailman/testing/i18n.py b/src/mailman/testing/i18n.py index 310815917..933a5ec0f 100644 --- a/src/mailman/testing/i18n.py +++ b/src/mailman/testing/i18n.py @@ -17,7 +17,7 @@ """Internationalization for the tests.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/tests/test_configfile.py b/src/mailman/tests/test_configfile.py index b4d169ba4..22442c767 100644 --- a/src/mailman/tests/test_configfile.py +++ b/src/mailman/tests/test_configfile.py @@ -17,7 +17,7 @@ """Test configuration file searching.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ @@ -121,7 +121,7 @@ class TestConfigFileSearch(TestConfigFileBase): with fakedirs(fake_testdir): # Write a mostly empty configuration file. with open(os.path.join(fake_testdir, 'mailman.cfg'), 'w') as fp: - print >> fp, '# Fake mailman.cfg file' + print('# Fake mailman.cfg file', file=fp) with chdir(fake_testdir): # Sometimes symlinks bite us (eg. OS X /var -> /private/var). found = os.path.realpath(search_for_configuration_file()) @@ -167,7 +167,7 @@ class TestConfigFileSearchWithChroot(TestConfigFileBase): with fakedirs(fake_testdir): # Write a mostly empty configuration file. with open(os.path.join(fake_testdir, 'mailman.cfg'), 'w') as fp: - print >> fp, '# Fake mailman.cfg file' + print('# Fake mailman.cfg file', file=fp) with hackenv('MAILMAN_CONFIG_FILE', config_file): self.assertEqual(search_for_configuration_file(), config_file) @@ -179,7 +179,7 @@ class TestConfigFileSearchWithChroot(TestConfigFileBase): with fakedirs(fake_testdir): # Write a mostly empty configuration file. with open(os.path.join(fake_testdir, '.mailman.cfg'), 'w') as fp: - print >> fp, '# Fake mailman.cfg file' + print('# Fake mailman.cfg file', file=fp) with hackenv('HOME', '/home/neil'): self.assertEqual(search_for_configuration_file(), config_file) @@ -191,7 +191,7 @@ class TestConfigFileSearchWithChroot(TestConfigFileBase): with fakedirs(fake_testdir): # Write a mostly empty configuration file. with open(os.path.join(fake_testdir, 'mailman.cfg'), 'w') as fp: - print >> fp, '# Fake mailman.cfg file' + print('# Fake mailman.cfg file', file=fp) self.assertEqual(search_for_configuration_file(), config_file) def test_sibling_directory(self): @@ -206,6 +206,6 @@ class TestConfigFileSearchWithChroot(TestConfigFileBase): os.mkdir(os.path.dirname(config_file)) # Write a mostly empty configuration file. with open(config_file, 'w') as fp: - print >> fp, '# Fake mailman.cfg file' - self.assertEqual(search_for_configuration_file(), + print('# Fake mailman.cfg file', file=fp) + self.assertEqual(search_for_configuration_file(), fake_config_file) diff --git a/src/mailman/utilities/datetime.py b/src/mailman/utilities/datetime.py index 37317d3f1..b494e2513 100644 --- a/src/mailman/utilities/datetime.py +++ b/src/mailman/utilities/datetime.py @@ -23,7 +23,7 @@ instrumented for testing purposes. """ -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/utilities/email.py b/src/mailman/utilities/email.py index c86ce0913..7025ddb89 100644 --- a/src/mailman/utilities/email.py +++ b/src/mailman/utilities/email.py @@ -17,7 +17,7 @@ """Email helpers.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/utilities/filesystem.py b/src/mailman/utilities/filesystem.py index ed215a6bd..f2a5b705b 100644 --- a/src/mailman/utilities/filesystem.py +++ b/src/mailman/utilities/filesystem.py @@ -17,7 +17,7 @@ """Filesystem utilities.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/utilities/interact.py b/src/mailman/utilities/interact.py index 9aa0e2491..8bca9ee40 100644 --- a/src/mailman/utilities/interact.py +++ b/src/mailman/utilities/interact.py @@ -17,7 +17,7 @@ """Provide an interactive prompt, mimicking the Python interpreter.""" -from __future__ import unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/utilities/mailbox.py b/src/mailman/utilities/mailbox.py index 306ac389c..4f085e127 100644 --- a/src/mailman/utilities/mailbox.py +++ b/src/mailman/utilities/mailbox.py @@ -17,7 +17,7 @@ """Module stuff.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/utilities/modules.py b/src/mailman/utilities/modules.py index 414af23ca..5dfec95db 100644 --- a/src/mailman/utilities/modules.py +++ b/src/mailman/utilities/modules.py @@ -17,7 +17,7 @@ """Package and module utilities.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/utilities/string.py b/src/mailman/utilities/string.py index 9f7a1dda9..0ed7cdf95 100644 --- a/src/mailman/utilities/string.py +++ b/src/mailman/utilities/string.py @@ -17,7 +17,7 @@ """String utilities.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/utilities/tests/test_import.py b/src/mailman/utilities/tests/test_import.py index 220310bd9..308fa8af2 100644 --- a/src/mailman/utilities/tests/test_import.py +++ b/src/mailman/utilities/tests/test_import.py @@ -26,8 +26,9 @@ __all__ = [ ] -import cPickle import os +import mock +import cPickle import unittest from datetime import timedelta, datetime @@ -107,7 +108,9 @@ class TestBasicImport(unittest.TestCase): for rname in ('members', 'digest_members'): roster = getattr(self._mlist, rname) self.assertFalse(isinstance(roster, dict)) - self._import() + # Suppress warning messages in test output. + with mock.patch('sys.stderr'): + self._import() self.assertFalse( isinstance(roster, dict), 'The %s roster has been overwritten by the import' % rname) @@ -256,7 +259,9 @@ class TestBasicImport(unittest.TestCase): 'Encoding to UTF-8 is not handled') # Test fallback to ascii with replace. self._pckdict[b'info'] = info.encode('iso-8859-1') - self._import() + # Suppress warning messages in test output. + with mock.patch('sys.stderr'): + self._import() self.assertEqual(self._mlist.info, unicode(self._pckdict[b'info'], 'ascii', 'replace'), "We don't fall back to replacing non-ascii chars") @@ -394,7 +399,9 @@ class TestMemberActionImport(unittest.TestCase): ) def _do_test(self, expected): - import_config_pck(self._mlist, self._pckdict) + # Suppress warning messages in the test output. + with mock.patch('sys.stderr'): + import_config_pck(self._mlist, self._pckdict) for key, value in expected.iteritems(): self.assertEqual(getattr(self._mlist, key), value) @@ -514,7 +521,9 @@ class TestConvertToURI(unittest.TestCase): self._pckdict[b'mail_host'] = b'test.example.com' self._pckdict[str(oldvar)] = test_value old_value = getattr(self._mlist, newvar) - import_config_pck(self._mlist, self._pckdict) + # Suppress warning messages in the test output. + with mock.patch('sys.stderr'): + import_config_pck(self._mlist, self._pckdict) new_value = getattr(self._mlist, newvar) self.assertEqual(old_value, new_value, 'Default value was not preserved for %s' % newvar) @@ -718,7 +727,9 @@ class TestRosterImport(unittest.TestCase): anne_addr = self._usermanager.create_address( 'anne@example.com', 'Anne') self._mlist.subscribe(anne_addr) - import_config_pck(self._mlist, self._pckdict) + # Suppress warning messages in test output. + with mock.patch('sys.stderr'): + import_config_pck(self._mlist, self._pckdict) anne = self._usermanager.get_user('anne@example.com') self.assertTrue(anne.controls('anne@example.com')) diff --git a/src/mailman/utilities/tests/test_wrap.py b/src/mailman/utilities/tests/test_wrap.py index 8d756e156..eca6f93be 100644 --- a/src/mailman/utilities/tests/test_wrap.py +++ b/src/mailman/utilities/tests/test_wrap.py @@ -17,7 +17,7 @@ """Test text wrapping.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ diff --git a/src/mailman/utilities/uid.py b/src/mailman/utilities/uid.py index c1df36789..4fe862868 100644 --- a/src/mailman/utilities/uid.py +++ b/src/mailman/utilities/uid.py @@ -21,7 +21,7 @@ Use these functions to create unique ids rather than inlining calls to hashlib and whatnot. These are better instrumented for testing purposes. """ -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ -- cgit v1.2.3-70-g09d2