Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#13494 closed (fixed)

Bad default for EMAIL_SUBJECT_PREFIX

Reported by: Henrique C. Alves Owned by: Andi Albrecht
Component: Core (Mail) Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The 'EMAIL_SUBJECT_PREFIX' setting is, by default, a string. This makes it break loud and needlessly if you pass a translation as the subject to 'mail_managers()':

TypeError 
cannot concatenate 'str' and '__proxy__' objects

The culprit line of django/core/mail.py:

 424. EmailMessage(settings.EMAIL_SUBJECT_PREFIX + subject, message, ...

Seems like an easy fix (just change the default setting to unicode?).

Attachments (2)

bug13494.diff (2.4 KB) - added by Andi Albrecht 6 years ago.
bug13494.2.diff (2.3 KB) - added by Andi Albrecht 6 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 6 years ago by Ramiro Morales

milestone: 2.0
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

A couple of workarounds could be wrapping your translatable subject with a call to call unicode() before passing it to mail_managers() or using string_concat().

comment:2 Changed 6 years ago by Russell Keith-Magee

Triage Stage: UnreviewedAccepted

Changed 6 years ago by Andi Albrecht

Attachment: bug13494.diff added

comment:3 Changed 6 years ago by Andi Albrecht

Has patch: set

comment:4 Changed 6 years ago by Andi Albrecht

Owner: changed from nobody to Andi Albrecht
Status: newassigned

comment:5 Changed 6 years ago by Jannis Leidel

milestone: 1.3

Changed 6 years ago by Andi Albrecht

Attachment: bug13494.2.diff added

comment:6 Changed 6 years ago by Jannis Leidel

Resolution: fixed
Status: assignedclosed

(In [14157]) Fixed #13494 -- Correctly concat an email subject prefix with a translation string. Thanks, hcarvalhoalves and Andi Albrecht.

comment:7 Changed 6 years ago by Jannis Leidel

(In [14159]) [1.2.X] Fixed #13494 -- Correctly concat an email subject prefix with a translation string. Thanks, hcarvalhoalves and Andi Albrecht.

Backport from trunk (r14157).

comment:8 Changed 5 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top