diff options
Diffstat (limited to 'src/mailman/core')
| -rw-r--r-- | src/mailman/core/initialize.py | 6 | ||||
| -rw-r--r-- | src/mailman/core/runner.py | 15 | ||||
| -rw-r--r-- | src/mailman/core/switchboard.py | 21 |
3 files changed, 21 insertions, 21 deletions
diff --git a/src/mailman/core/initialize.py b/src/mailman/core/initialize.py index c2395db10..6c7196990 100644 --- a/src/mailman/core/initialize.py +++ b/src/mailman/core/initialize.py @@ -39,7 +39,7 @@ __all__ = [ import os import sys -from pkg_resources import resource_string +from pkg_resources import resource_string as resource_bytes from zope.component import getUtility from zope.configuration import xmlconfig @@ -109,8 +109,8 @@ def initialize_1(config_path=None): :param config_path: The path to the configuration file. :type config_path: string """ - zcml = resource_string('mailman.config', 'configure.zcml') - xmlconfig.string(zcml) + zcml = resource_bytes('mailman.config', 'configure.zcml') + xmlconfig.string(zcml.decode('utf-8')) # By default, set the umask so that only owner and group can read and # write our files. Specifically we must have g+rw and we probably want # o-rwx although I think in most cases it doesn't hurt if other can read diff --git a/src/mailman/core/runner.py b/src/mailman/core/runner.py index 81a2ea3d1..d6aad2b07 100644 --- a/src/mailman/core/runner.py +++ b/src/mailman/core/runner.py @@ -30,12 +30,7 @@ import signal import logging import traceback -from cStringIO import StringIO from lazr.config import as_boolean, as_timedelta -from zope.component import getUtility -from zope.event import notify -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.core.logging import reopen @@ -44,6 +39,10 @@ from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.listmanager import IListManager from mailman.interfaces.runner import IRunner, RunnerCrashEvent from mailman.utilities.string import expand +from six.moves import cStringIO as StringIO +from zope.component import getUtility +from zope.event import notify +from zope.interface import implementer dlog = logging.getLogger('mailman.debug') @@ -218,11 +217,11 @@ class Runner: # them out of our sight. # # Find out which mailing list this message is destined for. + mlist = None missing = object() listname = msgdata.get('listname', missing) - mlist = (None - if listname is missing - else getUtility(IListManager).get(unicode(listname))) + if listname is missing: + mlist = getUtility(IListManager).get(listname.decode('utf-8')) if mlist is None: elog.error( '%s runner "%s" shunting message for missing list: %s', diff --git a/src/mailman/core/switchboard.py b/src/mailman/core/switchboard.py index 2e8ef24a7..78a12616e 100644 --- a/src/mailman/core/switchboard.py +++ b/src/mailman/core/switchboard.py @@ -37,22 +37,22 @@ import os import time import email import pickle -import cPickle import hashlib import logging -from zope.interface import implementer - from mailman.config import config from mailman.email.message import Message from mailman.interfaces.configuration import ConfigurationUpdatedEvent from mailman.interfaces.switchboard import ISwitchboard from mailman.utilities.filesystem import makedirs from mailman.utilities.string import expand +from six.moves import cPickle +from zope.interface import implementer -# 20 bytes of all bits set, maximum hashlib.sha.digest() value. -shamax = 0xffffffffffffffffffffffffffffffffffffffffL +# 20 bytes of all bits set, maximum hashlib.sha.digest() value. We do it this +# way for Python 2/3 compatibility. +shamax = int('0xffffffffffffffffffffffffffffffffffffffff', 16) # Small increment to add to time in case two entries have the same time. This # prevents skipping one of two entries with the same time until the next pass. DELTA = .0001 @@ -92,7 +92,7 @@ class Switchboard: self.queue_directory = queue_directory # If configured to, create the directory if it doesn't yet exist. if config.create_paths: - makedirs(self.queue_directory, 0770) + makedirs(self.queue_directory, 0o770) # Fast track for no slices self._lower = None self._upper = None @@ -123,7 +123,7 @@ class Switchboard: msgsave = cPickle.dumps(_msg, protocol) # listname is unicode but the input to the hash function must be an # 8-bit string (eventually, a bytes object). - hashfood = msgsave + listname.encode('utf-8') + repr(now) + hashfood = msgsave + listname + repr(now) # Encode the current time into the file name for FIFO sorting. The # file name consists of two parts separated by a '+': the received # time for this message (i.e. when it first showed up on this system) @@ -207,13 +207,13 @@ class Switchboard: # Throw out any files which don't match our bitrange. BAW: test # performance and end-cases of this algorithm. MAS: both # comparisons need to be <= to get complete range. - if lower is None or (lower <= long(digest, 16) <= upper): + if lower is None or (lower <= int(digest, 16) <= upper): key = float(when) while key in times: key += DELTA times[key] = filebase # FIFO sort - return [times[key] for key in sorted(times)] + return [times[k] for k in sorted(times)] def recover_backup_files(self): """See `ISwitchboard`.""" @@ -228,7 +228,8 @@ class Switchboard: dst = os.path.join(self.queue_directory, filebase + '.pck') with open(src, 'rb+') as fp: try: - msg = cPickle.load(fp) + # Throw away the message object. + cPickle.load(fp) data_pos = fp.tell() data = cPickle.load(fp) except Exception as error: |
