Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
db75bd6d
Commit
db75bd6d
authored
Mar 06, 2014
by
R David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#11558: Better message if attach called on non-multipart.
Original patch by Varun Sharma.
parent
49abb6f9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
1 deletion
+18
-1
Lib/email/message.py
Lib/email/message.py
+5
-1
Lib/test/test_email/test_email.py
Lib/test/test_email/test_email.py
+8
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+4
-0
No files found.
Lib/email/message.py
View file @
db75bd6d
...
@@ -203,7 +203,11 @@ class Message:
...
@@ -203,7 +203,11 @@ class Message:
if
self
.
_payload
is
None
:
if
self
.
_payload
is
None
:
self
.
_payload
=
[
payload
]
self
.
_payload
=
[
payload
]
else
:
else
:
try
:
self
.
_payload
.
append
(
payload
)
self
.
_payload
.
append
(
payload
)
except
AttributeError
:
raise
TypeError
(
"Attach is not valid on a message with a"
" non-multipart payload"
)
def
get_payload
(
self
,
i
=
None
,
decode
=
False
):
def
get_payload
(
self
,
i
=
None
,
decode
=
False
):
"""Return a reference to the payload.
"""Return a reference to the payload.
...
...
Lib/test/test_email/test_email.py
View file @
db75bd6d
...
@@ -124,6 +124,14 @@ class TestMessageAPI(TestEmailBase):
...
@@ -124,6 +124,14 @@ class TestMessageAPI(TestEmailBase):
msg
.
set_payload
([])
msg
.
set_payload
([])
self
.
assertEqual
(
msg
.
get_payload
(),
[])
self
.
assertEqual
(
msg
.
get_payload
(),
[])
def
test_attach_when_payload_is_string
(
self
):
msg
=
Message
()
msg
[
'Content-Type'
]
=
'multipart/mixed'
msg
.
set_payload
(
'string payload'
)
sub_msg
=
MIMEMessage
(
Message
())
self
.
assertRaisesRegex
(
TypeError
,
"[Aa]ttach.*non-multipart"
,
msg
.
attach
,
sub_msg
)
def
test_get_charsets
(
self
):
def
test_get_charsets
(
self
):
eq
=
self
.
assertEqual
eq
=
self
.
assertEqual
...
...
Misc/ACKS
View file @
db75bd6d
...
@@ -1188,6 +1188,7 @@ Daniel Shahaf
...
@@ -1188,6 +1188,7 @@ Daniel Shahaf
Ha Shao
Ha Shao
Mark Shannon
Mark Shannon
Richard Shapiro
Richard Shapiro
Varun Sharma
Vlad Shcherbina
Vlad Shcherbina
Justin Sheehy
Justin Sheehy
Charlie Shepherd
Charlie Shepherd
...
...
Misc/NEWS
View file @
db75bd6d
...
@@ -20,6 +20,10 @@ Core and Builtins
...
@@ -20,6 +20,10 @@ Core and Builtins
Library
Library
-------
-------
- Issue #11558: ``email.message.Message.attach`` now returns a more
useful error message if ``attach`` is called on a message for which
``is_multipart`` is False.
- Issue #20283: RE pattern methods now accept the string keyword parameters
- Issue #20283: RE pattern methods now accept the string keyword parameters
as documented. The pattern and source keyword parameters are left as
as documented. The pattern and source keyword parameters are left as
deprecated aliases.
deprecated aliases.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment