From 5dda12491e3e2233b63737a1c5f6066f54f6deb5 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Thu, 6 Mar 2014 11:44:17 -0500 Subject: #11558: Better message if attach called on non-multipart. Original patch by Varun Sharma. --- Lib/email/message.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Lib/email/message.py') diff --git a/Lib/email/message.py b/Lib/email/message.py index 88b5fa3552..b4bc8cbc9e 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. -- cgit v1.2.1