[issue1690608] email.utils.formataddr() should be rfc2047 aware

R. David Murray report at bugs.python.org
Sun Mar 27 16:28:55 CEST 2011


R. David Murray <rdmurray at bitdance.com> added the comment:

The general approach of the patch looks good to me.  Since formataddr is designed to be called from user code that is constructing a message, having it raise for non-ascii in the address is probably OK.  However, there should be a test for that, and I'm curious to know what happens if you use such an address in an address field in the unmodified email package.

Instead of directly calling bencode, you should use the charset module and its header_encode method.  Note that you need to turn the charset into a Charset instance first.  The advantage of doing this is that it will choose the "best" encoding to use based on the charset and the contents of the string.

Your choice of location for the new tests is fine; TestMiscelaneous really should be split up a bit, but that will wait until I do a general refactoring of the tests.

Thanks for working on this.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1690608>
_______________________________________


More information about the Python-bugs-list mailing list