gh-128949: Preserve payload line endings in BytesParser.parse - #157726
sankalpsthakur wants to merge 3 commits into
Conversation
|
Found a mailbox compatibility regression while investigating the Windows failures on 5a0df99: with CRLF storage, Maildir/MH now return CRLF payloads while A candidate follow-up keeps universal-newline conversion in |
|
The mailbox fix is in |
Link the documented class rather than its inherited parse method. The author reviewed and approved this one-line correction. AI-assisted: Codex.
Fixes #128949. Thanks to tnakamot and medmunds for the reports.
Disable universal-newline translation in the binary parser's
TextIOWrapper. CRLF and bare CR bytes in unencoded attachments must not become LF; parsing a binary file now agrees withparsebytes(). Header recognition and ownership of the caller's stream are unchanged.The follow-up in
9634201preservesmailbox.Message's existing universal-newline behavior for binary streams, without reverting the email parser fix. Bytes input still preserves line endings, and the caller's stream remains open.Regression coverage includes both policies, text/binary payloads, 7bit/8bit/binary transfer encodings, multipart attachments, an 8192-byte read boundary, header-only parsing, and mailbox stream/bytes construction with LF, CRLF and CR.
Validation
Original before/after run, Linux debug build based on
2385254: the new email assertions fail twice before the change and pass afterward. Thetest_email,test_mailbox,test_imaplib,test_poplibandtest_smtplibselection passes (2,629 tests run, 5 skipped);test_email -R 3:3andgit diff --checkpass. This run predates the mailbox follow-up.Upstream run 35378510395 for head
9634201completed with all seven Windows jobs and the other runtime test jobs passing. CLA, lint and label checks also pass. The workflow remains failed because Docs rejects the new NEWS reference toemail.parser.BytesHeaderParser.parse; the required-check aggregate consequently fails. The two-line NEWS correction is prepared but not pushed or Sphinx-tested.AI tools assisted with implementation, validation and this description.