This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients barry, python-dev, r.david.murray, vajrasky
Date 2014-02-08.17:09:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1391879379.27.0.132161881119.issue19772@psf.upfronthosting.co.za>
In-reply-to
Content
Vajrasky: thanks for your work on this, it helped me find a reasonable (if ugly) solution.  However, the 'if' statement in your patch that checks specifically for the combination of old and new cte of 8bit and base64 puzzles me.  The same problem occurs here if the CTE we end up with is quoted-printable, which will be the case, for example, for latin-1.  The logical way to think abut the problem here (we don't want to modify the message) would be "if the CTE changed, we need to restore it".  So why check specifically for 8bit and base64?  The straightforward translation of "if the CTE changed, we need to restore it" would have been: 'if self.orig_cte != cte'.

In my solution I preferred to leave the original object unchanged, and re-copy it to re-change the headers when needed.  This is ugly, but it is more future proof against the down-coding code someday changing other headers or other characteristics of the message.  And I needed to use deepcopy, because copy would just copy a pointer to the _headers list, and therefore the original headers list would still get modified.  The deepcopy isn't that costly here, though, because we know that it is only called on a message that is not a multipart, since the copies are triggered only from _handle_text.  It's still not pretty, but I think it is the best we can do without completely restructuring the way the generator does its work.
History
Date User Action Args
2014-02-08 17:09:39r.david.murraysetrecipients: + r.david.murray, barry, python-dev, vajrasky
2014-02-08 17:09:39r.david.murraysetmessageid: <1391879379.27.0.132161881119.issue19772@psf.upfronthosting.co.za>
2014-02-08 17:09:39r.david.murraylinkissue19772 messages
2014-02-08 17:09:37r.david.murraycreate