#!/usr/bin/env python # vim:set fileencoding=utf8: # from email.message import Message from email.mime.message import MIMEMessage msg = Message() msg.set_payload("A string payload") # This call to msg.attach() should generate a friendly exception # indicating that it is illegal to attach after setting a string payload. # At present, it fails with the following traceback: # Traceback (most recent call last): # File "test_email_attach_to_string.py", line 19, in # msg.attach(MIMEMessage(Message())) # File ".../Lib/email/message.py", line 196, in attach # self._payload.append(payload) # AttributeError: 'str' object has no attribute 'append' msg.attach(MIMEMessage(Message()))