#20371: mail_admins should support strings as arguments
-------------------------------+--------------------
     Reporter:  anonymous      |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Core (Mail)    |    Version:  1.5
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 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.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20371>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to