diff options
| author | Barry Warsaw | 2014-11-30 21:51:03 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2014-11-30 21:51:03 -0500 |
| commit | 44e43727be13e3554342c2b5b75b7dc42abdb18c (patch) | |
| tree | a0b97771f5d0856709ac8ab48c1e8f9eeecef352 /src/mailman/core/switchboard.py | |
| parent | 065060e56ac2445b6749b60480e9c42573854c5e (diff) | |
| download | mailman-44e43727be13e3554342c2b5b75b7dc42abdb18c.tar.gz mailman-44e43727be13e3554342c2b5b75b7dc42abdb18c.tar.zst mailman-44e43727be13e3554342c2b5b75b7dc42abdb18c.zip | |
Diffstat (limited to 'src/mailman/core/switchboard.py')
| -rw-r--r-- | src/mailman/core/switchboard.py | 21 |
1 files changed, 11 insertions, 10 deletions
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: |
