﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20371	mail_admins should support strings as arguments	anonymous	nobody	"As the topic says, mail_admins should support str-types as arguments, not only unicode data. The following example triggers an exception which is somewhat critical when used in combination with logging and the AdminEmailHandler:


{{{
from django.core.mail import mail_admins
subject=""Über""
mail.mail_admins(subject, ""test"")

>>> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 0: ordinal not in range(128)
}}}

Let me explain what the problem is here: A lot of people rely on the AdminEmailHandler which uses mail_admins. Now whenever an exception is raised it is a pretty common use-case to log the exception, like this:

{{{
try:
    bar = my_model.do_something()
except Exception, e:
    logger.critical(""do_something failed: %s"" %e)
    return False
else:
    return bar == 0
}}}

When the exception message contains unicode data, it will be converted to str. This will cause mail_admins to fail if non-ascii characaters were present."	Uncategorized	closed	Core (Mail)	1.5	Normal	invalid			Unreviewed	0	0	0	0	0	0
