Comment 3 for bug 597143

Revision history for this message
Martijn Pieters (mjpieters) wrote :

The fact that smtplib accepted unicode before was more of an accident than a feature, something that changed with an optimisation in the hmac module, see http://bugs.python.org/issue5285.

Patch looks correct to me. However, can someone find out if UTF-8 makes any sense here. I see a Django newsletter product encode to utf8 here (see http://github.com/Fantomas42/emencia-django-newsletter/issues/issue/1 for example), and so does Trac (http://trac.edgewall.org/ticket/8083). I'd like to see some confirmation though that SMTP servers accept non-ascii characters in usernames or passwords in UTF-8, or if there are any other encodings that need to be supported.

When the answer is that only ASCII is supported, I'd say UTF-8 is just fine here as it protects the user that enters a username and password that won't work anyway will not get a strange encoding error, just failure to send email (as expected).