[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')
except UnicodeEncodeError:
_charset = 'utf-8'
else:
_charset = 'latin-1'

This will make messages in most latin languages use quoted-printable encoding.

--
components: +email -Library (Lib)
nosy: +barry

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14380
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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
http://bugs.python.org/issue14380
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 rep...@bugs.python.org
http://bugs.python.org/issue14380
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 ascii codec is very fast, which you can't say about all the codecs).

Now, what would be *really* nice is to also try latin-1 before falling back to 
utf-8, but I wouldn't want to make that the default behavior for performance 
reasons.  I'm planning to add support for that at some point, but I haven't 
decided exactly how (policy setting? New optional setting in the alias 
structure?)

There seem to be unrelated changes to torture_test in your patch?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14380
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14380
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14380
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 don't manage to fix 7304 before 3.3 is ready, but with a comment about 
removing it when 7304 is fixed.

Thanks, Jeff.

--
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14380
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14380
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 
message.  Because someone might actually be making use of this bug, I'm not 
going to backport a fix, but I do want to make utf8 the default if there are 
non-ascii characters in the input, in a similar fashion to how it is done for 
headers (well, now that *that* bug has been fixed).

--
assignee: r.david.murray
components: Library (Lib)
keywords: easy
messages: 156501
nosy: mitya57, r.david.murray
priority: normal
severity: normal
stage: test needed
status: open
title: MIMEText should default to utf8 charset if input text contains non-ASCII
type: enhancement
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14380
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com