/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/email/emailer.py

  • Committer: Jelmer Vernooij
  • Date: 2019-08-11 13:21:03 UTC
  • mfrom: (7379 work)
  • mto: This revision was merged to the branch mainline in revision 7388.
  • Revision ID: jelmer@jelmer.uk-20190811132103-u3ne03yf37c1h57n
merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
        """Spawn a 'mail' subprocess to send the email."""
214
214
        # TODO think up a good test for this, but I think it needs
215
215
        # a custom binary shipped with. RBC 20051021
216
 
        msgfile = tempfile.NamedTemporaryFile()
217
 
        try:
 
216
        with tempfile.NamedTemporaryFile() as msgfile:
218
217
            msgfile.write(self.body().encode('utf8'))
219
218
            diff = self.get_diff()
220
219
            if diff:
229
228
            if rc != 0:
230
229
                raise errors.BzrError(
231
230
                    "Failed to send email: exit status %s" % (rc,))
232
 
        finally:
233
 
            msgfile.close()
234
231
 
235
232
    def _send_using_smtplib(self):
236
233
        """Use python's smtplib to send the email."""