You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mailbox.Babyl returns labels as bytes after reading a mailbox file #160598
'unseen' in msg.get_labels() is false, so converting the message to MaildirMessage or mboxMessage marks an unseen message as read (S, R).
Babyl.get_labels() does not leave out the special labels such as unseen.
If any message has labels, a change that makes flush() rewrite the file, such as remove(), fails with AttributeError, and so does adding such a message to another Babyl mailbox.
Babyl._generate_toc() reads the labels line in binary mode and keeps the labels as bytes, while _install_message() and _pre_mailbox_hook() write them with label.encode(). Decoding them in _generate_toc() fixes all of the above. Using errors='surrogateescape' for both the decoding and the encoding keeps files with labels that are not valid UTF-8 readable (today they can be read, only rewriting them fails). The existing test_labels never reopens the mailbox, so it doesn't catch this.
In the releases I tried (3.13.17, 3.14.9, 3.15.0) the example fails even earlier, with an AssertionError in get_message(), because of gh-157880, which is fixed on main, 3.15 and 3.14 after those releases. With the gh-157880 fix applied, 3.13 shows the same label problem.
Activity