Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Lib/mailbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,7 @@ def get_sequences(self):
with f:
all_keys = set(self.keys())
for line in f:
line = line.rstrip()
try:
name, contents = line.split(':')
keys = set()
Expand All @@ -1239,7 +1240,7 @@ def get_sequences(self):
del results[name]
except ValueError:
raise FormatError('Invalid sequence specification: %s' %
line.rstrip())
line)
return results

def set_sequences(self, sequences):
Expand Down Expand Up @@ -1291,7 +1292,7 @@ def pack(self):
self._next_key = prev + 1
if len(changes) == 0:
return
for name, key_list in sequences.items():
for key_list in sequences.values():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although we don't use the name variable here, but I think in now days we should fix one thing in a PR, I think this line's change is to trivial to touch it.

for old, new in changes:
if old in key_list:
key_list[key_list.index(old)] = new
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_mailbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,11 @@ def test_sequences(self):
msg0 = mailbox.MHMessage(self._template % 0)
msg0.add_sequence('foo')
key0 = self._box.add(msg0)
msg = self._box.get_message(key0)
self.assertEqual(len(msg.get_sequences()), 1)
self.assertEqual(msg.get_sequences()[0], 'foo')
self.assertEqual(msg['from'], 'foo')
self.assertEqual(msg.get_payload(), '0\n')
self.assertEqual(self._box.get_sequences(), {'foo':[key0]})
msg1 = mailbox.MHMessage(self._template % 1)
msg1.set_sequences(['bar', 'replied', 'foo'])
Expand Down
Loading