[Django] #27848: .eml could not be attached to EmailMessage

5 views
Skip to first unread message

Django

unread,
Feb 16, 2017, 4:02:35 AM2/16/17
to django-...@googlegroups.com
#27848: .eml could not be attached to EmailMessage
---------------------------------------+------------------------
Reporter: doudz | Owner: nobody
Type: Bug | Status: new
Component: Core (Mail) | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+------------------------
.eml file could not be attached to EmailMessage using .attach_file()
because it raise the following error :
initial_value must be str or None, not bytes

maybe related to mimetype message/rfc822

{{{
File "/usr/local/lib/python3.5/dist-packages/django/core/mail/message.py",
line 292, in send return
self.get_connection(fail_silently).send_messages([self])
File "/usr/local/lib/python3.5/dist-
packages/django/core/mail/backends/smtp.py", line 107, in send_messages
sent = self._send(message)
File "/usr/local/lib/python3.5/dist-
packages/django/core/mail/backends/smtp.py", line 121, in _send message =
email_message.message()
File "/usr/local/lib/python3.5/dist-packages/django/core/mail/message.py",
line 256, in message msg = self._create_message(msg)
File "/usr/local/lib/python3.5/dist-packages/django/core/mail/message.py",
line 344, in _create_message return self._create_attachments(msg)
File "/usr/local/lib/python3.5/dist-packages/django/core/mail/message.py",
line 357, in _create_attachments
msg.attach(self._create_attachment(*attachment)) File
"/usr/local/lib/python3.5/dist-packages/django/core/mail/message.py", line
399, in _create_attachment attachment =
self._create_mime_attachment(content, mimetype)
File "/usr/local/lib/python3.5/dist-packages/django/core/mail/message.py",
line 380, in _create_mime_attachment content =
message_from_string(content) File "/usr/lib/python3.5/email/__init__.py",
line 38, in message_from_string return Parser(*args, **kws).parsestr(s)
File "/usr/lib/python3.5/email/parser.py", line 68, in parsestr return
self.parse(StringIO(text), headersonly=headersonly)
TypeError: initial_value must be str or None, not bytes
}}}

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

Django

unread,
Feb 16, 2017, 4:03:13 AM2/16/17
to django-...@googlegroups.com
#27848: .eml could not be attached to EmailMessage
-----------------------------+--------------------------------------

Reporter: doudz | Owner: nobody
Type: Bug | Status: new
Component: Core (Mail) | Version: 1.9
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Description changed by doudz:

Old description:

New description:

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27848#comment:1>

Django

unread,
Feb 16, 2017, 4:03:37 AM2/16/17
to django-...@googlegroups.com
#27848: .eml could not be attached to EmailMessage
-----------------------------+--------------------------------------

Reporter: doudz | Owner: nobody
Type: Bug | Status: new
Component: Core (Mail) | Version: 1.9
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Description changed by doudz:

Old description:

> .eml file could not be attached to EmailMessage using .attach_file()

New description:

--

--
Ticket URL: <https://code.djangoproject.com/ticket/27848#comment:2>

Django

unread,
Feb 16, 2017, 7:47:59 AM2/16/17
to django-...@googlegroups.com
#27848: EmailMessage.attach_file() with .eml file crashes
----------------------------------+------------------------------------
Reporter: RAMAGE Sébastien | Owner: nobody

Type: Bug | Status: new
Component: Core (Mail) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


Comment:

Reproduced with the attached test.

--
Ticket URL: <https://code.djangoproject.com/ticket/27848#comment:3>

Django

unread,
Feb 16, 2017, 7:48:12 AM2/16/17
to django-...@googlegroups.com
#27848: EmailMessage.attach_file() with .eml file crashes
----------------------------------+------------------------------------
Reporter: RAMAGE Sébastien | Owner: nobody

Type: Bug | Status: new
Component: Core (Mail) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Tim Graham):

* Attachment "27848-test.diff" added.

Django

unread,
Feb 16, 2017, 9:58:03 AM2/16/17
to django-...@googlegroups.com
#27848: EmailMessage.attach_file() with .eml file crashes
-------------------------------------+-------------------------------------
Reporter: RAMAGE Sébastien | Owner: Dariush
| Azimi
Type: Bug | Status: assigned

Component: Core (Mail) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Dariush Azimi):

* owner: nobody => Dariush Azimi
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/27848#comment:4>

Django

unread,
Mar 8, 2017, 9:44:08 AM3/8/17
to django-...@googlegroups.com
#27848: EmailMessage.attach_file() with .eml file crashes
-------------------------------------+-------------------------------------
Reporter: RAMAGE Sébastien | Owner: Dariush
| Azimi
Type: Bug | Status: assigned
Component: Core (Mail) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Dariush):

Hi Ramage,

Trying to reproduce the error. Can you provide the steps to reproduce the
error? I see the test case but that is all there is.

Thanks
Dariush

Replying to [ticket:27848 RAMAGE Sébastien]:

--
Ticket URL: <https://code.djangoproject.com/ticket/27848#comment:5>

Django

unread,
Mar 8, 2017, 10:21:28 AM3/8/17
to django-...@googlegroups.com
#27848: EmailMessage.attach_file() with .eml file crashes
-------------------------------------+-------------------------------------
Reporter: RAMAGE Sébastien | Owner: Dariush
| Azimi
Type: Bug | Status: assigned
Component: Core (Mail) | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

To reproduce, apply the patch I provided and run that test from the Django
test suite.

--
Ticket URL: <https://code.djangoproject.com/ticket/27848#comment:6>

Django

unread,
Apr 1, 2017, 9:11:55 AM4/1/17
to django-...@googlegroups.com
#27848: EmailMessage.attach_file() with .eml file crashes
----------------------------------+------------------------------------
Reporter: RAMAGE Sébastien | Owner: (none)
Type: Bug | Status: new
Component: Core (Mail) | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+------------------------------------
Changes (by Claude Paroz):

* status: assigned => new
* owner: Dariush Azimi => (none)
* has_patch: 0 => 1
* version: 1.9 => master


Comment:

[https://github.com/django/django/pull/8281 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/27848#comment:7>

Django

unread,
Apr 1, 2017, 10:05:28 AM4/1/17
to django-...@googlegroups.com
#27848: EmailMessage.attach_file() with .eml file crashes
-------------------------------------+-------------------------------------

Reporter: RAMAGE Sébastien | Owner: (none)
Type: Bug | Status: new

Component: Core (Mail) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/27848#comment:8>

Django

unread,
Apr 1, 2017, 10:19:55 AM4/1/17
to django-...@googlegroups.com
#27848: EmailMessage.attach_file() with .eml file crashes
-------------------------------------+-------------------------------------
Reporter: RAMAGE Sébastien | Owner: Claude
| Paroz <claude@…>
Type: Bug | Status: closed

Component: Core (Mail) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

* owner: (none) => Claude Paroz <claude@…>
* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"9a9e22832166594e3561fa1911dd255a2fb09b2b" 9a9e2283]:
{{{
#!CommitTicketReference repository=""
revision="9a9e22832166594e3561fa1911dd255a2fb09b2b"
Fixed #27848 -- Prevented crash when attaching a .eml file to a message

Thanks Sébastien Ramage for the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27848#comment:9>

Reply all
Reply to author
Forward
0 new messages