Message210593
Actually, I am thinking of this approach (cloning the message just after entering the flatten method):
diff -r b541ecd32115 Lib/email/generator.py
--- a/Lib/email/generator.py Fri Feb 07 16:11:17 2014 -0800
+++ b/Lib/email/generator.py Sat Feb 08 15:55:01 2014 +0800
@@ -67,7 +67,7 @@
# Just delegate to the file object
self._fp.write(s)
- def flatten(self, msg, unixfrom=False, linesep=None):
+ def flatten(self, msg_obj, unixfrom=False, linesep=None):
r"""Print the message object tree rooted at msg to the output file
specified when the Generator instance was created.
@@ -86,6 +86,8 @@
# from the msg, and _encoded_XXX constants for operating on data that
# has already been converted (to bytes in the BytesGenerator) and
# inserted into a temporary buffer.
+ import copy
+ msg = copy.copy(msg_obj)
policy = msg.policy if self.policy is None else self.policy
if linesep is not None:
policy = policy.clone(linesep=linesep)
It works for this bug but apparently it fails one test.
======================================================================
FAIL: test_make_boundary (__main__.TestMessageAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
File "Lib/test/test_email/test_email.py", line 199, in test_make_boundary
'multipart/form-data; boundary="==')
AssertionError: 'multipart/form-data' != 'multipart/form-data; boundary="=='
- multipart/form-data
+ multipart/form-data; boundary="==
So somehow, according to the ultimate design of email library, msg can not leave flatten method unscratched. :) |
|
Date |
User |
Action |
Args |
2014-02-08 08:14:43 | vajrasky | set | recipients:
+ vajrasky, barry, r.david.murray |
2014-02-08 08:14:43 | vajrasky | set | messageid: <1391847283.26.0.0573727630863.issue19772@psf.upfronthosting.co.za> |
2014-02-08 08:14:43 | vajrasky | link | issue19772 messages |
2014-02-08 08:14:42 | vajrasky | create | |
|