Problems with email.Generator.Generator
Steve Holden
steve at holdenweb.com
Mon Sep 11 11:50:25 EDT 2006
Chris Withers wrote:
> Peter Otten wrote:
>
>>http://sourceforge.net/tracker/?func=detail&aid=1409455&group_id=5470&atid=105470
>>
>>>Now, is this change to Generator.py in error or am I doing something
>>>wrong?
>>
>>I'm not familiar enough with the email package to answer that.
>
>
> I'm hoping someone around here is ;-)
>
>
>>>If the latter, how can I change my code such that it works as I'd expect?
>>
>>email.Generator and email.Message use cStringIO.StringIO internally, which
>>can't cope with unicode. A quick fix might be to monkey-patch:
>
>
> I'm not sure that's correct, but I'm happy to stand corrected.
>
> My understanding is that the StringIO's don't mind as long as they type
> is consistent - ie: con't mix unicode and encoded strings, 'cos it
> forced python's default ascii codec to kick in and spew unicode errors.
>
> Now, I want to know what I'm supposed to do when I have unicode source
> and want it to end up as either a text/plain or text/html mime part.
>
> Is there a how-to for this anywhere? The email package's docs are short
> on examples involving charsets, unicode and the like :-(
>
Well, it would seem like the easiest approach is to monkey-patch the use
of cStringIO to StringIO as recommended and see if that fixes your
problem. Wouldn't it?
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list
mailing list