[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-06-02 Thread Dmitry Shachnev
Dmitry Shachnev mity...@gmail.com added the comment: Maybe it'll be better to use 'latin-1' charset for latin-1 texts? Something like this: if _charset == 'us-ascii': try: _text.encode(_charset) except UnicodeEncodeError: try: _text.encode('latin-1')

[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-06-02 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: I do plan to add something like that at some point. You could open a new issue for it if you like, and propose a formal patch. -- ___ Python tracker rep...@bugs.python.org

[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-03-22 Thread Jeff Knupp
Jeff Knupp jkn...@gmail.com added the comment: Patch to default character set to utf8 if non-ascii characters are found in the input string. Please let me know if this is what you had in mind. -- nosy: +Jeff.Knupp ___ Python tracker

[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-03-22 Thread Jeff Knupp
Changes by Jeff Knupp jkn...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file24997/mailutf8.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14380 ___

[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-03-22 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Pretty close. I'd do the check for us_ascii first, and only do the encode test/switch to utf-8 if that's the charset. The reason is that that if a charset has been specified, we don't waste time doing an unnecessary encoding (and the

[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-03-22 Thread Jeff Knupp
Jeff Knupp jkn...@gmail.com added the comment: Understood. Please take a look at the updated patch. Also, removed the unrelated diffs that somehow were hanging around in my hg mq. -- Added file: http://bugs.python.org/file24999/mimeutf8.patch ___

[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-03-22 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: That looks good. -- stage: test needed - commit review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14380 ___

[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-03-22 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset bfd1ba2bbaf8 by R David Murray in branch 'default': #14380: Have MIMEText defaults to utf-8 when passed non-ASCII unicode http://hg.python.org/cpython/rev/bfd1ba2bbaf8 -- nosy: +python-dev

[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-03-22 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: See also issue 7304. It was niggling at the back of my brain, and I finally managed to dig it up. Fixing that is much more complex than fixing this (because set_charset is a *very* strange method), so I committed this patch in case we

[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-03-22 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 9ceac471bd8c by R David Murray in branch 'default': #14380: Make actual default match docs, fix __init__ order. http://hg.python.org/cpython/rev/9ceac471bd8c -- ___

[issue14380] MIMEText should default to utf8 charset if input text contains non-ASCII

2012-03-21 Thread R. David Murray
New submission from R. David Murray rdmur...@bitdance.com: The MIMEText class of the email package in Python3 requires that a character set be specified in order for the resulting email to be valid. If no character set is specified, it currently assumes ascii but puts a unicode payload in the