diff options
| -rw-r--r-- | src/mailman/app/subscriptions.py | 4 | ||||
| -rw-r--r-- | src/mailman/commands/cli_import.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_members.py | 2 | ||||
| -rw-r--r-- | src/mailman/commands/cli_qfile.py | 6 | ||||
| -rw-r--r-- | src/mailman/commands/docs/echo.rst | 2 | ||||
| -rw-r--r-- | src/mailman/commands/docs/help.rst | 6 | ||||
| -rw-r--r-- | src/mailman/commands/docs/inject.rst | 2 | ||||
| -rw-r--r-- | src/mailman/commands/docs/members.rst | 3 | ||||
| -rw-r--r-- | src/mailman/commands/docs/membership.rst | 18 | ||||
| -rw-r--r-- | src/mailman/commands/docs/qfile.rst | 8 | ||||
| -rw-r--r-- | src/mailman/commands/docs/withlist.rst | 4 | ||||
| -rw-r--r-- | src/mailman/commands/tests/test_help.py | 4 | ||||
| -rw-r--r-- | src/mailman/model/requests.py | 2 | ||||
| -rw-r--r-- | src/mailman/runners/command.py | 2 | ||||
| -rw-r--r-- | src/mailman/utilities/importer.py | 6 |
15 files changed, 36 insertions, 35 deletions
diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py index ac6368c2a..620b99c20 100644 --- a/src/mailman/app/subscriptions.py +++ b/src/mailman/app/subscriptions.py @@ -26,6 +26,8 @@ __all__ = [ ] +import six + from operator import attrgetter from passlib.utils import generate_password as generate from sqlalchemy import and_, or_ @@ -108,7 +110,7 @@ class SubscriptionService: # the parameter can either be an email address or a user id. query = [] if subscriber is not None: - if isinstance(subscriber, basestring): + if isinstance(subscriber, six.text_type): # subscriber is an email address. address = user_manager.get_address(subscriber) user = user_manager.get_user(subscriber) diff --git a/src/mailman/commands/cli_import.py b/src/mailman/commands/cli_import.py index b53faea96..7b18b888c 100644 --- a/src/mailman/commands/cli_import.py +++ b/src/mailman/commands/cli_import.py @@ -77,7 +77,7 @@ class Import21: assert len(args.pickle_file) == 1, ( 'Unexpected positional arguments: %s' % args.pickle_file) filename = args.pickle_file[0] - with open(filename) as fp: + with open(filename, 'rb') as fp: while True: try: config_dict = cPickle.load(fp) diff --git a/src/mailman/commands/cli_members.py b/src/mailman/commands/cli_members.py index 291fda3b7..756771877 100644 --- a/src/mailman/commands/cli_members.py +++ b/src/mailman/commands/cli_members.py @@ -197,8 +197,6 @@ class Members: continue # Parse the line and ensure that the values are unicodes. display_name, email = parseaddr(line) - display_name = display_name.decode(fp.encoding) - email = email.decode(fp.encoding) # Give the user a default, user-friendly password. password = generate(int(config.passwords.password_length)) try: diff --git a/src/mailman/commands/cli_qfile.py b/src/mailman/commands/cli_qfile.py index c4ff66aea..499476772 100644 --- a/src/mailman/commands/cli_qfile.py +++ b/src/mailman/commands/cli_qfile.py @@ -25,6 +25,8 @@ __all__ = [ ] +import six + from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.utilities.interact import interact @@ -69,7 +71,7 @@ class QFile: """See `ICLISubCommand`.""" printer = PrettyPrinter(indent=4) assert len(args.qfile) == 1, 'Wrong number of positional arguments' - with open(args.qfile[0]) as fp: + with open(args.qfile[0], 'rb') as fp: while True: try: m.append(cPickle.load(fp)) @@ -80,7 +82,7 @@ class QFile: for i, obj in enumerate(m): count = i + 1 print(_('<----- start object $count ----->')) - if isinstance(obj, basestring): + if isinstance(obj, six.string_types): print(obj) else: printer.pprint(obj) diff --git a/src/mailman/commands/docs/echo.rst b/src/mailman/commands/docs/echo.rst index 686accf2c..6412a4afe 100644 --- a/src/mailman/commands/docs/echo.rst +++ b/src/mailman/commands/docs/echo.rst @@ -24,7 +24,7 @@ The original message is ignored, but the results receive the echoed command. >>> from mailman.email.message import Message >>> print(command.process(mlist, Message(), {}, ('foo', 'bar'), results)) ContinueProcessing.yes - >>> print(results.decode('utf-8')) + >>> print(str(results)) The results of your email command are provided below. <BLANKLINE> echo foo bar diff --git a/src/mailman/commands/docs/help.rst b/src/mailman/commands/docs/help.rst index 35ba87caa..5330a0b79 100644 --- a/src/mailman/commands/docs/help.rst +++ b/src/mailman/commands/docs/help.rst @@ -25,7 +25,7 @@ short description of each of them. >>> from mailman.email.message import Message >>> print(help.process(mlist, Message(), {}, (), results)) ContinueProcessing.yes - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> confirm - Confirm a subscription request. @@ -44,7 +44,7 @@ With an argument, you can get more detailed help about a specific command. >>> results = Results() >>> print(help.process(mlist, Message(), {}, ('help',), results)) ContinueProcessing.yes - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> help [command] @@ -56,7 +56,7 @@ Some commands have even more detailed help. >>> results = Results() >>> print(help.process(mlist, Message(), {}, ('join',), results)) ContinueProcessing.yes - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> join [digest=<no|mime|plain>] diff --git a/src/mailman/commands/docs/inject.rst b/src/mailman/commands/docs/inject.rst index 63e7b0366..16cf81661 100644 --- a/src/mailman/commands/docs/inject.rst +++ b/src/mailman/commands/docs/inject.rst @@ -133,7 +133,7 @@ Standard input The message text can also be provided on standard input. :: - >>> from StringIO import StringIO + >>> from six import StringIO # Remember: we've got unicode literals turned on. >>> standard_in = StringIO(str("""\ diff --git a/src/mailman/commands/docs/members.rst b/src/mailman/commands/docs/members.rst index 7b99e92f9..5ec1521a5 100644 --- a/src/mailman/commands/docs/members.rst +++ b/src/mailman/commands/docs/members.rst @@ -229,9 +229,8 @@ You can also specify ``-`` as the filename, in which case the addresses are taken from standard input. :: - >>> from StringIO import StringIO + >>> from six import StringIO >>> fp = StringIO() - >>> fp.encoding = 'us-ascii' >>> for address in ('dperson@example.com', ... 'Elly Person <eperson@example.com>', ... 'fperson@example.com (Fred Person)', diff --git a/src/mailman/commands/docs/membership.rst b/src/mailman/commands/docs/membership.rst index 3fe9b05ba..a260e930a 100644 --- a/src/mailman/commands/docs/membership.rst +++ b/src/mailman/commands/docs/membership.rst @@ -45,7 +45,7 @@ If that's missing though, then an error is returned. >>> from mailman.email.message import Message >>> print(join.process(mlist, Message(), {}, (), results)) ContinueProcessing.no - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> join: No valid address found to subscribe @@ -60,7 +60,7 @@ The ``subscribe`` command is an alias. >>> results = Results() >>> print(subscribe.process(mlist, Message(), {}, (), results)) ContinueProcessing.no - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> subscribe: No valid address found to subscribe @@ -79,7 +79,7 @@ When the message has a From field, that address will be subscribed. >>> results = Results() >>> print(join.process(mlist, msg, {}, (), results)) ContinueProcessing.yes - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> Confirmation email sent to Anne Person <anne@example.com> @@ -150,7 +150,7 @@ list. >>> results = Results() >>> print(confirm.process(mlist, msg, {}, (token,), results)) ContinueProcessing.yes - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> Confirmed @@ -208,7 +208,7 @@ list. >>> results = Results() >>> print(confirm.process(mlist_2, msg, {}, (token,), results)) ContinueProcessing.yes - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> Confirmed @@ -241,7 +241,7 @@ is sent a confirmation message for her request. >>> results = Results() >>> print(leave.process(mlist_2, msg, {}, (), results)) ContinueProcessing.yes - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> Anne Person <anne@example.com> left baker@example.com @@ -278,7 +278,7 @@ to unsubscribe Anne from the alpha mailing list. >>> print(leave.process(mlist, msg, {}, (), results)) ContinueProcessing.no - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> Invalid or unverified email address: anne.person@example.org @@ -299,7 +299,7 @@ unsubscribe her from the list. >>> print(leave.process(mlist, msg, {}, (), results)) ContinueProcessing.yes - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> Anne Person <anne.person@example.org> left alpha@example.com @@ -354,7 +354,7 @@ a user of the system. >>> print(confirm.process(mlist, msg, {}, (token,), results)) ContinueProcessing.yes - >>> print(results.decode('utf-8')) + >>> print(results) The results of your email command are provided below. <BLANKLINE> Confirmed diff --git a/src/mailman/commands/docs/qfile.rst b/src/mailman/commands/docs/qfile.rst index 8ec0a3952..721d63567 100644 --- a/src/mailman/commands/docs/qfile.rst +++ b/src/mailman/commands/docs/qfile.rst @@ -55,11 +55,11 @@ Once we've figured out the file name of the shunted message, we can print it. I borkeded Mailman. <BLANKLINE> <----- start object 2 -----> - { u'_parsemsg': False, - 'bad': u'yes', - 'bar': u'baz', + { '_parsemsg': False, + 'bad': 'yes', + 'bar': 'baz', 'foo': 7, - u'version': 3} + 'version': 3} [----- end pickle -----] Maybe we don't want to print the contents of the file though, in case we want diff --git a/src/mailman/commands/docs/withlist.rst b/src/mailman/commands/docs/withlist.rst index e915eb04c..321b6e68a 100644 --- a/src/mailman/commands/docs/withlist.rst +++ b/src/mailman/commands/docs/withlist.rst @@ -52,10 +52,10 @@ single argument, the mailing list. >>> with open(os.path.join(config.VAR_DIR, 'showme.py'), 'w') as fp: ... print("""\ ... def showme(mailing_list): - ... print "The list's name is", mailing_list.fqdn_listname + ... 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 + ... 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 diff --git a/src/mailman/commands/tests/test_help.py b/src/mailman/commands/tests/test_help.py index 74eaae84e..ea8105d2a 100644 --- a/src/mailman/commands/tests/test_help.py +++ b/src/mailman/commands/tests/test_help.py @@ -51,7 +51,7 @@ class TestHelp(unittest.TestCase): ('more', 'than', 'one'), results) self.assertEqual(status, ContinueProcessing.no) - self.assertEqual(results.decode('utf-8'), """\ + self.assertEqual(str(results), """\ The results of your email command are provided below. help: too many arguments: more than one @@ -63,7 +63,7 @@ help: too many arguments: more than one status = self._help.process(self._mlist, Message(), {}, ('doesnotexist',), results) self.assertEqual(status, ContinueProcessing.no) - self.assertEqual(results.decode('utf-8'), """\ + self.assertEqual(str(results), """\ The results of your email command are provided below. help: no such command: doesnotexist diff --git a/src/mailman/model/requests.py b/src/mailman/model/requests.py index e8428244a..394084b71 100644 --- a/src/mailman/model/requests.py +++ b/src/mailman/model/requests.py @@ -53,7 +53,6 @@ class DataPendable(dict): for key, value in mapping.items(): assert isinstance(key, six.string_types) if not isinstance(value, six.text_type): - import pdb; pdb.set_trace() key = '_pck_' + key value = dumps(value).decode('raw-unicode-escape') clean_mapping[key] = value @@ -115,7 +114,6 @@ class ListRequests: @dbconnection def get_request(self, store, request_id, request_type=None): - import pdb; pdb.set_trace() result = store.query(_Request).get(request_id) if result is None: return None diff --git a/src/mailman/runners/command.py b/src/mailman/runners/command.py index 54ab03687..f6884de5f 100644 --- a/src/mailman/runners/command.py +++ b/src/mailman/runners/command.py @@ -141,7 +141,7 @@ The results of your email command are provided below. text = text.decode(self.charset, 'ignore') self._output.write(text) - def __unicode__(self): + def __str__(self): value = self._output.getvalue() assert isinstance(value, six.text_type), 'Not a unicode: %r' % value return value diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py index 5cc52fef7..a75ee4535 100644 --- a/src/mailman/utilities/importer.py +++ b/src/mailman/utilities/importer.py @@ -27,6 +27,7 @@ __all__ = [ import os +import six import sys import codecs import datetime @@ -282,7 +283,7 @@ def import_config_pck(mlist, config_dict): ban_manager.ban(str_to_unicode(address)) # Handle acceptable aliases. acceptable_aliases = config_dict.get('acceptable_aliases', '') - if isinstance(acceptable_aliases, basestring): + if isinstance(acceptable_aliases, six.string_types): acceptable_aliases = acceptable_aliases.splitlines() alias_set = IAcceptableAliasSet(mlist) for address in acceptable_aliases: @@ -343,7 +344,8 @@ def import_config_pck(mlist, config_dict): if oldvar not in config_dict: continue text = config_dict[oldvar] - text = text.decode('utf-8', 'replace') + if isinstance(text, bytes): + text = text.decode('utf-8', 'replace') for oldph, newph in convert_placeholders: text = text.replace(oldph, newph) default_value, default_text = defaults.get(newvar, (None, None)) |
