Code review comment for lp:~edwin-grubbs/bzr/bug-384158-passing-body-to-mutt

Edwin Grubbs (edwin-grubbs) wrote :

> > This branch adds the ability to pass the email body into mutt. I tried using
> a
> > NamedTemporaryFile as Martin suggested, but the file got deleted immediately
> > by garbage collection.
>
> Is that because bzr send exits before mutt is finished? If not, is it
> possible to hold a reference to the variable, but perhaps there's no easy
> scope to do so. It's not a big deal, but having a comment might be good.

I added a comment. Here is the incremental diff:

{{{
=== modified file 'bzrlib/mail_client.py'
--- bzrlib/mail_client.py 2009-06-06 03:25:19 +0000
+++ bzrlib/mail_client.py 2009-06-07 01:16:59 +0000
@@ -271,6 +271,9 @@
             message_options.extend(['-a',
                 self._encode_path(attach_path, 'attachment')])
         if body is not None:
+ # mkstemp() is used instead of NamedTemporaryFile, so that
+ # the file won't be deleted when the object gets garbage
+ # collected, which may be before mutt can read it.
             fd, temp_file = tempfile.mkstemp(prefix="mutt-body-",
                                              suffix=".txt")
             try:

}}}

« Back to merge proposal