summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2014-03-06 16:44:17 (GMT)
committerR David Murray <rdmurray@bitdance.com>2014-03-06 16:44:17 (GMT)
commit5dda12491e3e2233b63737a1c5f6066f54f6deb5 (patch)
treeadb09127fa2582cf98e47f3e643b7ba7f8a36001 /Lib/email
parent733e50ad9ee2885323c39080b42716fa5d1fd8c1 (diff)
downloadcpython-5dda12491e3e2233b63737a1c5f6066f54f6deb5.zip
cpython-5dda12491e3e2233b63737a1c5f6066f54f6deb5.tar.gz
cpython-5dda12491e3e2233b63737a1c5f6066f54f6deb5.tar.bz2
#11558: Better message if attach called on non-multipart.
Original patch by Varun Sharma.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/message.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/email/message.py b/Lib/email/message.py
index 88b5fa3..b4bc8cb 100644
--- a/Lib/email/message.py
+++ b/Lib/email/message.py
@@ -203,7 +203,11 @@ class Message:
if self._payload is None:
self._payload = [payload]
else:
- self._payload.append(payload)
+ try:
+ 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):
"""Return a reference to the payload.