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, msapiro, r.david.murray
Date 2020-01-20.15:42:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1579534947.75.0.777687400618.issue39384@roundup.psfhosted.org>
In-reply-to
Content
Since you parsed it as a string it is not really legitimate to serialize it as bytes.  (That will work if the input message only contains ascii, but not if it contains unicode).  You'll get the same error if you replace the garbage with the "’".  Using errors=replace is not crazy, but it hides the actual problem.  Let's see what other people think :)

In theory you could "fix" this by encoding the unicode using the charset specified by the container.  I have no idea how complicated it will be do that, and it would be a new feature: parsing strings is specified to only work with ASCII input, currently.

I put "fix" in quotes, because even if you make text parts like this example work, you still can't handle non-text 8bit mime parts.  Is it worth doing anyway?

Really, message_as_string and friends should just be avoided entirely, maybe even deprecated.
History
Date User Action Args
2020-01-20 15:42:27r.david.murraysetrecipients: + r.david.murray, barry, msapiro
2020-01-20 15:42:27r.david.murraysetmessageid: <1579534947.75.0.777687400618.issue39384@roundup.psfhosted.org>
2020-01-20 15:42:27r.david.murraylinkissue39384 messages
2020-01-20 15:42:27r.david.murraycreate