diff options
author | R David Murray <rdmurray@bitdance.com> | 2016-09-07 20:48:35 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2016-09-07 20:48:35 (GMT) |
commit | 56b1f1b4d5edef1ca6184225145cffc59d2b3b5d (patch) | |
tree | 305f7b097d8798b86f376a10cc27f928cb27d7a2 /Doc | |
parent | 3788b85628eb9e8e802374303e14c04b6a817d97 (diff) | |
download | cpython-56b1f1b4d5edef1ca6184225145cffc59d2b3b5d.zip cpython-56b1f1b4d5edef1ca6184225145cffc59d2b3b5d.tar.gz cpython-56b1f1b4d5edef1ca6184225145cffc59d2b3b5d.tar.bz2 |
#27331: add policy keyword argument to all MIME subclasses.
Patch by Berker Peksag.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/email.mime.rst | 53 | ||||
-rw-r--r-- | Doc/whatsnew/3.6.rst | 7 |
2 files changed, 53 insertions, 7 deletions
diff --git a/Doc/library/email.mime.rst b/Doc/library/email.mime.rst index 8297dea..165011d 100644 --- a/Doc/library/email.mime.rst +++ b/Doc/library/email.mime.rst @@ -25,7 +25,7 @@ Here are the classes: .. currentmodule:: email.mime.base -.. class:: MIMEBase(_maintype, _subtype, **_params) +.. class:: MIMEBase(_maintype, _subtype, *, policy=compat32, **_params) Module: :mod:`email.mime.base` @@ -41,10 +41,17 @@ Here are the classes: key/value dictionary and is passed directly to :meth:`Message.add_header <email.message.Message.add_header>`. + If *policy* is specified, (defaults to the + :class:`compat32 <email.policy.Compat32>` policy) it will be passed to + :class:`~email.message.Message`. + The :class:`MIMEBase` class always adds a :mailheader:`Content-Type` header (based on *_maintype*, *_subtype*, and *_params*), and a :mailheader:`MIME-Version` header (always set to ``1.0``). + .. versionchanged:: 3.6 + Added *policy* keyword-only parameter. + .. currentmodule:: email.mime.nonmultipart @@ -62,7 +69,8 @@ Here are the classes: .. currentmodule:: email.mime.multipart -.. class:: MIMEMultipart(_subtype='mixed', boundary=None, _subparts=None, **_params) +.. class:: MIMEMultipart(_subtype='mixed', boundary=None, _subparts=None, \ + *, policy=compat32, **_params) Module: :mod:`email.mime.multipart` @@ -82,14 +90,20 @@ Here are the classes: to the message by using the :meth:`Message.attach <email.message.Message.attach>` method. + Optional *policy* argument defaults to :class:`compat32 <email.policy.Compat32>`. + Additional parameters for the :mailheader:`Content-Type` header are taken from the keyword arguments, or passed into the *_params* argument, which is a keyword dictionary. + .. versionchanged:: 3.6 + Added *policy* keyword-only parameter. .. currentmodule:: email.mime.application -.. class:: MIMEApplication(_data, _subtype='octet-stream', _encoder=email.encoders.encode_base64, **_params) +.. class:: MIMEApplication(_data, _subtype='octet-stream', \ + _encoder=email.encoders.encode_base64, \ + *, policy=compat32, **_params) Module: :mod:`email.mime.application` @@ -109,12 +123,18 @@ Here are the classes: object as necessary. The default encoding is base64. See the :mod:`email.encoders` module for a list of the built-in encoders. + Optional *policy* argument defaults to :class:`compat32 <email.policy.Compat32>`. + *_params* are passed straight through to the base class constructor. + .. versionchanged:: 3.6 + Added *policy* keyword-only parameter. .. currentmodule:: email.mime.audio -.. class:: MIMEAudio(_audiodata, _subtype=None, _encoder=email.encoders.encode_base64, **_params) +.. class:: MIMEAudio(_audiodata, _subtype=None, \ + _encoder=email.encoders.encode_base64, \ + *, policy=compat32, **_params) Module: :mod:`email.mime.audio` @@ -137,12 +157,18 @@ Here are the classes: object as necessary. The default encoding is base64. See the :mod:`email.encoders` module for a list of the built-in encoders. + Optional *policy* argument defaults to :class:`compat32 <email.policy.Compat32>`. + *_params* are passed straight through to the base class constructor. + .. versionchanged:: 3.6 + Added *policy* keyword-only parameter. .. currentmodule:: email.mime.image -.. class:: MIMEImage(_imagedata, _subtype=None, _encoder=email.encoders.encode_base64, **_params) +.. class:: MIMEImage(_imagedata, _subtype=None, \ + _encoder=email.encoders.encode_base64, \ + *, policy=compat32, **_params) Module: :mod:`email.mime.image` @@ -165,13 +191,17 @@ Here are the classes: object as necessary. The default encoding is base64. See the :mod:`email.encoders` module for a list of the built-in encoders. + Optional *policy* argument defaults to :class:`compat32 <email.policy.Compat32>`. + *_params* are passed straight through to the :class:`~email.mime.base.MIMEBase` constructor. + .. versionchanged:: 3.6 + Added *policy* keyword-only parameter. .. currentmodule:: email.mime.message -.. class:: MIMEMessage(_msg, _subtype='rfc822') +.. class:: MIMEMessage(_msg, _subtype='rfc822', *, policy=compat32) Module: :mod:`email.mime.message` @@ -184,10 +214,14 @@ Here are the classes: Optional *_subtype* sets the subtype of the message; it defaults to :mimetype:`rfc822`. + Optional *policy* argument defaults to :class:`compat32 <email.policy.Compat32>`. + + .. versionchanged:: 3.6 + Added *policy* keyword-only parameter. .. currentmodule:: email.mime.text -.. class:: MIMEText(_text, _subtype='plain', _charset=None) +.. class:: MIMEText(_text, _subtype='plain', _charset=None, *, policy=compat32) Module: :mod:`email.mime.text` @@ -211,5 +245,10 @@ Here are the classes: will automatically encode the new payload (and add a new :mailheader:`Content-Transfer-Encoding` header). + Optional *policy* argument defaults to :class:`compat32 <email.policy.Compat32>`. + .. versionchanged:: 3.5 *_charset* also accepts :class:`~email.charset.Charset` instances. + + .. versionchanged:: 3.6 + Added *policy* keyword-only parameter. diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst index 7ab4c97..ebb142c 100644 --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -455,6 +455,13 @@ Any code relying on the presence of ``default_format`` may need to be adapted. See :issue:`27819` for more details. +email +----- + +The :mod:`email.mime` classes now all accept an optional *policy* keyword. +(Contributed by Berker Peksag in :issue:`27331`.) + + encodings --------- |