[issue19772] str serialization of Message object may mutate the payload and CTE.

2014-02-09 Thread Vajrasky Kok
Vajrasky Kok added the comment: > So why check specifically for 8bit and base64? I was in hurry when creating this patch. I think that was part of the debug code. This patch was created with the purpose to illuminate the culprit of this bug. And it served its purpose. After uploading this pat

[issue19772] str serialization of Message object may mutate the payload and CTE.

2014-02-08 Thread R. David Murray
R. David Murray added the comment: 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

[issue19772] str serialization of Message object may mutate the payload and CTE.

2014-02-08 Thread R. David Murray
Changes by R. David Murray : -- resolution: -> fixed stage: needs patch -> committed/rejected status: open -> closed ___ Python tracker ___ _

[issue19772] str serialization of Message object may mutate the payload and CTE.

2014-02-08 Thread Roundup Robot
Roundup Robot added the comment: New changeset 34fb36972f8d by R David Murray in branch '3.3': #19772: Do not mutate message when downcoding to 7bit. http://hg.python.org/cpython/rev/34fb36972f8d New changeset 2e97d3500970 by R David Murray in branch 'default': Merge #19772: Do not mutate messag

[issue19772] str serialization of Message object may mutate the payload and CTE.

2014-02-08 Thread R. David Murray
R. David Murray added the comment: Ah, it is because the boundary computation intentionally modifies the message object. Which is a questionable design decision overall, but is now set in stone :(. -- ___ Python tracker

[issue19772] str serialization of Message object may mutate the payload and CTE.

2014-02-08 Thread R. David Murray
R. David Murray added the comment: I'm guessing the problem is that copy is a shallow copy, and message objects can be deeply nested. Doing a deepcopy might work, but as things are currently, that could cost a lot of memory, so I don't want to do that. --

[issue19772] str serialization of Message object may mutate the payload and CTE.

2014-02-08 Thread Vajrasky Kok
Vajrasky Kok added the comment: 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.pyFri Feb 07 16:11:17 2014 -0800 +++ b/Lib/email/generator.pySat Feb 08 15:55:01 2

[issue19772] str serialization of Message object may mutate the payload and CTE.

2014-02-07 Thread Vajrasky Kok
Vajrasky Kok added the comment: > Your test method didn't start with 'test_', so it didn't get run. Ah sorry about that. This is the updated patch. It fixed the problem and passed all test. -- Added file: http://bugs.python.org/file33987/fix_serialization_message_object_mutation_v4.pa

[issue19772] str serialization of Message object may mutate the payload and CTE.

2014-02-07 Thread R. David Murray
R. David Murray added the comment: While the copy solution seems reasonable, unfortunately it looks like the solution isn't that simple. Your test method didn't start with 'test_', so it didn't get run. Your fix doesn't fix the problem, since other parts of the code are holding on to a point

[issue19772] str serialization of Message object may mutate the payload and CTE.

2013-11-27 Thread Vajrasky Kok
Vajrasky Kok added the comment: I got another inspiration. The third patch uses copy.copy to copy the Message before mutating it in string generator, then restore it after printing the mutated message. -- Added file: http://bugs.python.org/file32867/fix_serialization_message_object_mu

[issue19772] str serialization of Message object may mutate the payload and CTE.

2013-11-27 Thread Vajrasky Kok
Vajrasky Kok added the comment: The second patch copies the private variables of the message before mutating it in string generator, then restore the private variables after printing the mutated message. -- Added file: http://bugs.python.org/file32866/fix_serialization_message_object_

[issue19772] str serialization of Message object may mutate the payload and CTE.

2013-11-27 Thread Vajrasky Kok
Vajrasky Kok added the comment: I come out with two patches. The first patch using bytes generator to copy the message before mutating it in string generator, then restore it after printing the mutated message. -- keywords: +patch Added file: http://bugs.python.org/file32865/fix_seria

[issue19772] str serialization of Message object may mutate the payload and CTE.

2013-11-25 Thread R. David Murray
New submission from R. David Murray: Currently the string generator will downcast 8bit body parts to 7bit by encoding them using a 7bit CTE. This is good. However, the way it does it is to modify the Message object accordingly. This is not good. Except for filling in required missing bits