~rashi007/mailman/docsfix

« back to all changes in this revision

Viewing changes to src/mailman/model/messagestore.py

  • Committer: Barry Warsaw
  • Date: 2014-12-02 03:02:08 UTC
  • mto: (7264.4.22 py3)
  • mto: This revision was merged to the branch mainline in revision 7285.
  • Revision ID: barry@list.org-20141202030208-45txxq70yn98uz9m
test_requests succeeds now, after changing some LargeBinary columns into
Unicode columns.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
            raise ValueError(
65
65
                'Message ID already exists in message store: {0}'.format(
66
66
                    message_id))
67
 
        shaobj = hashlib.sha1(message_id)
68
 
        hash32 = base64.b32encode(shaobj.digest())
 
67
        shaobj = hashlib.sha1(message_id.encode('utf-8'))
 
68
        hash32 = base64.b32encode(shaobj.digest()).decode('utf-8')
69
69
        del message['X-Message-ID-Hash']
70
70
        message['X-Message-ID-Hash'] = hash32
71
71
        # Calculate the path on disk where we're going to store this message
90
90
        # them and try again.
91
91
        while True:
92
92
            try:
93
 
                with open(path, 'w') as fp:
 
93
                with open(path, 'wb') as fp:
94
94
                    # -1 says to use the highest protocol available.
95
95
                    pickle.dump(message, fp, -1)
96
96
                    break
102
102
 
103
103
    def _get_message(self, row):
104
104
        path = os.path.join(config.MESSAGES_DIR, row.path)
105
 
        with open(path) as fp:
 
105
        with open(path, 'rb') as fp:
106
106
            return pickle.load(fp)
107
107
 
108
108
    @dbconnection