From 0a1776fc9fdf8e03757f2ccc08f5267489472432 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Fri, 11 Jun 2021 09:59:21 -0400 Subject: Save mbox files with proper unixfrom In order to avoid some of the more obscure charset encoding problems, we switched to using as_string() for generating messages before saving them in an mbox file. However, this uncovered a bug where the unixfrom was not actually generated and saved, despite as_bytes() and as_string() supposedly behaving identically. See: https://docs.python.org/3/library/email.message.html#email.message.EmailMessage.as_string This commit fixes the problem by properly setting the unixfrom and using the recommended (and hopefully less buggy) email.generator interface when saving mailboxes. Reported-by: Geert Uytterhoeven Signed-off-by: Konstantin Ryabitsev --- b4/mbox.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'b4/mbox.py') diff --git a/b4/mbox.py b/b4/mbox.py index eeccaf2..e722d05 100644 --- a/b4/mbox.py +++ b/b4/mbox.py @@ -125,12 +125,12 @@ def make_am(msgs, cmdargs, msgid): if save_maildir: b4.save_maildir(am_msgs, am_filename) else: - with open(am_filename, 'wb') as fh: + with open(am_filename, 'w') as fh: b4.save_git_am_mbox(am_msgs, fh) else: am_filename = None am_cover = None - b4.save_git_am_mbox(am_msgs, sys.stdout.buffer) + b4.save_git_am_mbox(am_msgs, sys.stdout) logger.info('---') @@ -603,7 +603,7 @@ def main(cmdargs): logger.info('%s messages in the thread', len(msgs)) if cmdargs.outdir == '-': logger.info('---') - b4.save_git_am_mbox(msgs, sys.stdout.buffer) + b4.save_git_am_mbox(msgs, sys.stdout) return # Check if outdir is a maildir @@ -646,7 +646,7 @@ def main(cmdargs): logger.info('Saved maildir %s', savename) return - with open(savename, 'wb') as fh: + with open(savename, 'w') as fh: b4.save_git_am_mbox(msgs, fh) logger.info('Saved %s', savename) -- cgit v1.2.3