diff options
author | R David Murray <rdmurray@bitdance.com> | 2014-03-06 16:44:17 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2014-03-06 16:44:17 (GMT) |
commit | 5dda12491e3e2233b63737a1c5f6066f54f6deb5 (patch) | |
tree | adb09127fa2582cf98e47f3e643b7ba7f8a36001 /Lib/email | |
parent | 733e50ad9ee2885323c39080b42716fa5d1fd8c1 (diff) | |
download | cpython-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.py | 6 |
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. |