diff options
Diffstat (limited to 'src/mailman/model/messagestore.py')
| -rw-r--r-- | src/mailman/model/messagestore.py | 9 |
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: |
