diff --git a/Lib/email/MIMEAudio.py b/Lib/email/MIMEAudio.py index 57b7b6da99d..be8599b8b3a 100644 --- a/Lib/email/MIMEAudio.py +++ b/Lib/email/MIMEAudio.py @@ -6,9 +6,9 @@ import sndhdr from cStringIO import StringIO -import MIMEBase -import Errors -import Encoders +from email import Errors +from email import Encoders +from email.MIMENonMultipart import MIMENonMultipart @@ -37,7 +37,7 @@ def _whatsnd(data): -class MIMEAudio(MIMEBase.MIMEBase): +class MIMEAudio(MIMENonMultipart): """Class for generating audio/* MIME documents.""" def __init__(self, _audiodata, _subtype=None, @@ -66,6 +66,6 @@ class MIMEAudio(MIMEBase.MIMEBase): _subtype = _whatsnd(_audiodata) if _subtype is None: raise TypeError, 'Could not find audio MIME subtype' - MIMEBase.MIMEBase.__init__(self, 'audio', _subtype, **_params) + MIMENonMultipart.__init__(self, 'audio', _subtype, **_params) self.set_payload(_audiodata) _encoder(self) diff --git a/Lib/email/MIMEBase.py b/Lib/email/MIMEBase.py index 28816e8ae22..7485d855c4f 100644 --- a/Lib/email/MIMEBase.py +++ b/Lib/email/MIMEBase.py @@ -4,7 +4,7 @@ """Base class for MIME specializations. """ -import Message +from email import Message diff --git a/Lib/email/MIMEImage.py b/Lib/email/MIMEImage.py index f0e7931a14c..29b0ea11aaf 100644 --- a/Lib/email/MIMEImage.py +++ b/Lib/email/MIMEImage.py @@ -6,14 +6,13 @@ import imghdr -# Intrapackage imports -import MIMEBase -import Errors -import Encoders +from email import Errors +from email import Encoders +from email.MIMENonMultipart import MIMENonMultipart -class MIMEImage(MIMEBase.MIMEBase): +class MIMEImage(MIMENonMultipart): """Class for generating image/* type MIME documents.""" def __init__(self, _imagedata, _subtype=None, @@ -41,6 +40,6 @@ class MIMEImage(MIMEBase.MIMEBase): _subtype = imghdr.what(None, _imagedata) if _subtype is None: raise TypeError, 'Could not guess image MIME subtype' - MIMEBase.MIMEBase.__init__(self, 'image', _subtype, **_params) + MIMENonMultipart.__init__(self, 'image', _subtype, **_params) self.set_payload(_imagedata) _encoder(self) diff --git a/Lib/email/MIMEMessage.py b/Lib/email/MIMEMessage.py index 89da92503ab..8fa86cb5b43 100644 --- a/Lib/email/MIMEMessage.py +++ b/Lib/email/MIMEMessage.py @@ -4,12 +4,12 @@ """Class representing message/* MIME documents. """ -import Message -import MIMEBase +from email import Message +from email.MIMENonMultipart import MIMENonMultipart -class MIMEMessage(MIMEBase.MIMEBase): +class MIMEMessage(MIMENonMultipart): """Class representing message/* MIME documents.""" def __init__(self, _msg, _subtype='rfc822'): @@ -22,7 +22,9 @@ class MIMEMessage(MIMEBase.MIMEBase): default is "rfc822" (this is defined by the MIME standard, even though the term "rfc822" is technically outdated by RFC 2822). """ - MIMEBase.MIMEBase.__init__(self, 'message', _subtype) + MIMENonMultipart.__init__(self, 'message', _subtype) if not isinstance(_msg, Message.Message): raise TypeError, 'Argument is not an instance of Message' - self.set_payload(_msg) + # It's convenient to use this base class method. We need to do it + # this way or we'll get an exception + Message.Message.attach(self, _msg) diff --git a/Lib/email/MIMEText.py b/Lib/email/MIMEText.py index 8669d285683..048f544f6cd 100644 --- a/Lib/email/MIMEText.py +++ b/Lib/email/MIMEText.py @@ -5,12 +5,12 @@ """ import warnings -import MIMEBase -from Encoders import encode_7or8bit +from email.MIMENonMultipart import MIMENonMultipart +from email.Encoders import encode_7or8bit -class MIMEText(MIMEBase.MIMEBase): +class MIMEText(MIMENonMultipart): """Class for generating text/* type MIME documents.""" def __init__(self, _text, _subtype='plain', _charset='us-ascii', @@ -33,8 +33,8 @@ class MIMEText(MIMEBase.MIMEBase): override any header settings indicated by _charset. This is probably not what you want. """ - MIMEBase.MIMEBase.__init__(self, 'text', _subtype, - **{'charset': _charset}) + MIMENonMultipart.__init__(self, 'text', _subtype, + **{'charset': _charset}) if _text and _text[-1] <> '\n': _text += '\n' self.set_payload(_text, _charset)