diff options
| author | R. David Murray <rdmurray@bitdance.com> | 2010-12-12 20:32:19 (GMT) |
|---|---|---|
| committer | R. David Murray <rdmurray@bitdance.com> | 2010-12-12 20:32:19 (GMT) |
| commit | 910c52fcf4ef25ce4c765aa3f2733704b4adaab7 (patch) | |
| tree | 04101918ec5d58ba77156f41b243ea66a44db30c | |
| parent | 0b883012c4b50a7428f39db91ec7ead93eae2ab0 (diff) | |
| download | cpython-910c52fcf4ef25ce4c765aa3f2733704b4adaab7.zip cpython-910c52fcf4ef25ce4c765aa3f2733704b4adaab7.tar.gz cpython-910c52fcf4ef25ce4c765aa3f2733704b4adaab7.tar.bz2 | |
Merged revisions 87191 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r87191 | r.david.murray | 2010-12-12 15:06:19 -0500 (Sun, 12 Dec 2010) | 6 lines
#243654: only create a new MIME boundary if we don't already have one.
The rearranged code should do exactly what the old code did, but
the new code avoids a potentially costly re computation in the case
where a boundary already exists.
........
| -rw-r--r-- | Lib/email/generator.py | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/Lib/email/generator.py b/Lib/email/generator.py index fa45dcb..717a6c6 100644 --- a/Lib/email/generator.py +++ b/Lib/email/generator.py @@ -202,19 +202,13 @@ class Generator: g = self.clone(s) g.flatten(part, unixfrom=False) msgtexts.append(s.getvalue()) - # Now make sure the boundary we've selected doesn't appear in any of - # the message texts. - alltext = NL.join(msgtexts) # BAW: What about boundaries that are wrapped in double-quotes? - boundary = msg.get_boundary(failobj=_make_boundary(alltext)) - # If we had to calculate a new boundary because the body text - # contained that string, set the new boundary. We don't do it - # unconditionally because, while set_boundary() preserves order, it - # doesn't preserve newlines/continuations in headers. This is no big - # deal in practice, but turns out to be inconvenient for the unittest - # suite. - if msg.get_boundary() != boundary: - msg.set_boundary(boundary) + boundary = msg.get_boundary() + if not boundary: + # Create a boundary that doesn't appear in any of the + # message texts. + alltext = NL.join(msgtexts) + msg.set_boundary(self._make_boundary(alltext)) # If there's a preamble, write it out, with a trailing CRLF if msg.preamble is not None: print >> self._fp, msg.preamble |
