Opened 5 years ago

Closed 4 years ago

Last modified 3 years ago

#13494 closed (fixed)

Bad default for EMAIL_SUBJECT_PREFIX

Reported by: hcarvalhoalves Owned by: andialbrecht
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 andialbrecht 4 years ago.
bug13494.2.diff (2.3 KB) - added by andialbrecht 4 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 years ago by ramiro

  • milestone 2.0 deleted
  • 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 5 years ago by russellm

  • Triage Stage changed from Unreviewed to Accepted

Changed 4 years ago by andialbrecht

comment:3 Changed 4 years ago by andialbrecht

  • Has patch set

comment:4 Changed 4 years ago by andialbrecht

  • Owner changed from nobody to andialbrecht
  • Status changed from new to assigned

comment:5 Changed 4 years ago by jezdez

  • milestone set to 1.3

Changed 4 years ago by andialbrecht

comment:6 Changed 4 years ago by jezdez

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:7 Changed 4 years ago by jezdez

(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 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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