Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#28042 closed Bug (fixed)

mimetype Fallback for attachments passed to EmailMessage.__init__ removed

Reported by: Dariusz Paluch Owned by: Nikolay
Component: Core (Mail) Version: 1.11
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Dariusz Paluch)

>>> m = EmailMessage(attachments=[('filename1', 'content1',)])
>>> m.attach('filename2', 'content2')
>>> m.attachments
[('filename1', 'content1'),
 ('filename2', 'content2', 'application/octet-stream')]
>>> m.message()
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/IPython/core/interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-53-5151166d7cfd>", line 1, in <module>
    m.message()
  File "/usr/local/lib/python3.4/dist-packages/django/core/mail/message.py", line 302, in message
    msg = self._create_message(msg)
  File "/usr/local/lib/python3.4/dist-packages/django/core/mail/message.py", line 399, in _create_message
    return self._create_attachments(msg)
  File "/usr/local/lib/python3.4/dist-packages/django/core/mail/message.py", line 412, in _create_attachments
    msg.attach(self._create_attachment(*attachment))
  File "/usr/local/lib/python3.4/dist-packages/django/core/mail/message.py", line 450, in _create_attachment
    attachment = self._create_mime_attachment(content, mimetype)
  File "/usr/local/lib/python3.4/dist-packages/django/core/mail/message.py", line 422, in _create_mime_attachment
    basetype, subtype = mimetype.split('/', 1)
AttributeError: 'NoneType' object has no attribute 'split'

This code was work in 1.10

Change History (9)

comment:1 by Tim Graham, 8 years ago

Component: UncategorizedCore (Mail)
Description: modified (diff)

Can you please provide code to reproduce the issue?

comment:2 by Dariusz Paluch, 8 years ago

Description: modified (diff)

comment:3 by Tim Graham, 8 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:4 by Nikolay, 8 years ago

Owner: changed from nobody to Nikolay
Status: newassigned

comment:5 by Nikolay, 8 years ago

Resolution: fixed
Status: assignedclosed

comment:6 by Tim Graham, 8 years ago

Has patch: set
Resolution: fixed
Status: closednew

The ticket is closed when the patch is merged. Please check "Has patch" when adding a pull request. See Triaging Tickets for workflow details.

comment:7 by Tim Graham, 8 years ago

Patch needs improvement: set

comment:8 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In dd00184:

Fixed #28042 -- Fixed crash when using a two-tuple in EmailMessage's attachments arg.

comment:9 by Tim Graham <timograham@…>, 8 years ago

In 734e6bb2:

[1.11.x] Fixed #28042 -- Fixed crash when using a two-tuple in EmailMessage's attachments arg.

Backport of dd001848920713fe616c03db6946762e8aa7c4e3 from master

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