summaryrefslogtreecommitdiff
path: root/src/mailman/model/messagestore.py
diff options
context:
space:
mode:
authorBarry Warsaw2014-09-27 20:17:05 -0400
committerBarry Warsaw2014-09-27 20:17:05 -0400
commit2fcc921b2cca02976a7b1ca8da4f15d55595974e (patch)
treea992a10f3859b892287bf7d2510bdd190cf457db /src/mailman/model/messagestore.py
parentb3500aefb15c63ccf60ab4508868f770ffd2d309 (diff)
parent95fc64b4894e5985bb8d0e5e944b2cda38c9a58c (diff)
downloadmailman-2fcc921b2cca02976a7b1ca8da4f15d55595974e.tar.gz
mailman-2fcc921b2cca02976a7b1ca8da4f15d55595974e.tar.zst
mailman-2fcc921b2cca02976a7b1ca8da4f15d55595974e.zip
Diffstat (limited to 'src/mailman/model/messagestore.py')
-rw-r--r--src/mailman/model/messagestore.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mailman/model/messagestore.py b/src/mailman/model/messagestore.py
index 225d3d1ce..19fa8133f 100644
--- a/src/mailman/model/messagestore.py
+++ b/src/mailman/model/messagestore.py
@@ -66,7 +66,7 @@ class MessageStore:
'Message ID already exists in message store: {0}'.format(
message_id))
shaobj = hashlib.sha1(message_id)
- hash32 = base64.b32encode(shaobj.digest()).decode('ascii')
+ hash32 = base64.b32encode(shaobj.digest())
del message['X-Message-ID-Hash']
message['X-Message-ID-Hash'] = hash32
# Calculate the path on disk where we're going to store this message
@@ -115,8 +115,11 @@ class MessageStore:
@dbconnection
def get_message_by_hash(self, store, message_id_hash):
- if isinstance(message_id_hash, bytes):
- message_id_hash = message_id_hash.decode('utf-8')
+ # It's possible the hash came from a message header, in which case it
+ # will be a Unicode. However when coming from source code, it may be
+ # bytes object. Coerce to the latter if necessary; it must be ASCII.
+ if not isinstance(message_id_hash, bytes):
+ message_id_hash = message_id_hash.encode('ascii')
row = store.query(Message).filter_by(
message_id_hash=message_id_hash).first()
if row is None: