summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2014-12-01 22:34:31 -0500
committerBarry Warsaw2014-12-01 22:34:31 -0500
commitfecb83c9b7b9c8d7c3d8ee7cf16be8fb1e76fedc (patch)
treec80714ab8d2ec67e05d4106f4afb21b85d9afbab
parent590c96831bd03f193d07a063b8ee35b14416dc28 (diff)
downloadmailman-fecb83c9b7b9c8d7c3d8ee7cf16be8fb1e76fedc.tar.gz
mailman-fecb83c9b7b9c8d7c3d8ee7cf16be8fb1e76fedc.tar.zst
mailman-fecb83c9b7b9c8d7c3d8ee7cf16be8fb1e76fedc.zip
-rw-r--r--src/mailman/app/templates.py2
-rw-r--r--src/mailman/core/switchboard.py13
2 files changed, 7 insertions, 8 deletions
diff --git a/src/mailman/app/templates.py b/src/mailman/app/templates.py
index d0c278e3a..742f8c0b2 100644
--- a/src/mailman/app/templates.py
+++ b/src/mailman/app/templates.py
@@ -55,7 +55,7 @@ class MailmanHandler(BaseHandler):
assert parsed.scheme == 'mailman'
# The path can contain one, two, or three components. Since no empty
# path components are legal, filter them out.
- parts = filter(None, parsed.path.split('/'))
+ parts = [p for p in parsed.path.split('/') if p is not None]
if len(parts) == 0:
raise URLError('No template specified')
elif len(parts) == 1:
diff --git a/src/mailman/core/switchboard.py b/src/mailman/core/switchboard.py
index 78a12616e..d635a12e9 100644
--- a/src/mailman/core/switchboard.py
+++ b/src/mailman/core/switchboard.py
@@ -114,21 +114,20 @@ class Switchboard:
data.update(_kws)
listname = data.get('listname', '--nolist--')
# Get some data for the input to the sha hash.
- now = time.time()
+ now = repr(time.time())
if data.get('_plaintext'):
protocol = 0
msgsave = cPickle.dumps(str(_msg), protocol)
else:
protocol = pickle.HIGHEST_PROTOCOL
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 + repr(now)
+ # listname is a str but the input to the hash function must be a bytes.
+ hashfood = msgsave + listname.encode('utf-8') + now.encode('utf-8')
# 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)
# and the sha hex digest.
- filebase = repr(now) + '+' + hashlib.sha1(hashfood).hexdigest()
+ filebase = now + '+' + hashlib.sha1(hashfood).hexdigest()
filename = os.path.join(self.queue_directory, filebase + '.pck')
tmpfile = filename + '.tmp'
# Always add the metadata schema version number
@@ -142,7 +141,7 @@ class Switchboard:
# object or not.
data['_parsemsg'] = (protocol == 0)
# Write to the pickle file the message object and metadata.
- with open(tmpfile, 'w') as fp:
+ with open(tmpfile, 'wb') as fp:
fp.write(msgsave)
cPickle.dump(data, fp, protocol)
fp.flush()
@@ -156,7 +155,7 @@ class Switchboard:
filename = os.path.join(self.queue_directory, filebase + '.pck')
backfile = os.path.join(self.queue_directory, filebase + '.bak')
# Read the message object and metadata.
- with open(filename) as fp:
+ with open(filename, 'rb') as fp:
# Move the file to the backup file name for processing. If this
# process crashes uncleanly the .bak file will be used to
# re-instate the .pck file in order to try again.