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')
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
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
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
___
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
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
___
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
___
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
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
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
--
___
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
11 matches
Mail list logo