Repository navigation
gh-160598: Decode labels read from a Babyl mailbox file - #160613
Open
devdavidejesus wants to merge 1 commit into
Open
devdavidejesus wants to merge 1 commit into
devdavidejesus wants to merge 1 commit into
Conversation
Babyl._generate_toc() kept the labels read from the file as bytes, but they are written with str.encode() and the rest of the code expects strings. Use errors='surrogateescape' in both directions so that labels that are not valid UTF-8 still round-trip.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Babyl._generate_toc()kept the labels read from the file as bytes, but they are written withlabel.encode()and everything else expects strings. As a result, labels read back werebytes,'unseen' in msg.get_labels()was false (so unseen messages became read when converted to Maildir or mbox),Babyl.get_labels()included the special labels, and rewriting the mailbox failed withAttributeError. Decode them the same way they are encoded. Both directions useerrors='surrogateescape', so a mailbox with labels that are not valid UTF-8 can still be opened (as it can today) and its labels are written back unchanged.The two new tests reopen the mailbox; they fail without the change and pass with it, and
test_mailboxpasses. Tested on macOS.See #160598.