[Python-checkins] cpython: Add policy keyword to email.generator.DecodedGenerator.

r.david.murray python-checkins at python.org
Thu Sep 8 17:57:19 EDT 2016


https://hg.python.org/cpython/rev/9d50309875ff
changeset:   103365:9d50309875ff
parent:      103363:dcd0fa6ab699
user:        R David Murray <rdmurray at bitdance.com>
date:        Thu Sep 08 17:57:06 2016 -0400
summary:
  Add policy keyword to email.generator.DecodedGenerator.

files:
  Doc/library/email.generator.rst |  6 +++---
  Doc/whatsnew/3.6.rst            |  4 ++++
  Lib/email/generator.py          |  6 ++++--
  Misc/NEWS                       |  2 ++
  4 files changed, 13 insertions(+), 5 deletions(-)


diff --git a/Doc/library/email.generator.rst b/Doc/library/email.generator.rst
--- a/Doc/library/email.generator.rst
+++ b/Doc/library/email.generator.rst
@@ -234,7 +234,8 @@
 represented in the output stream by a string derived from a template filled
 in with information about the part.
 
-.. class:: DecodedGenerator(outfp, mangle_from_=None, maxheaderlen=78, fmt=None)
+.. class:: DecodedGenerator(outfp, mangle_from_=None, maxheaderlen=None, \
+                            fmt=None, *, policy=None)
 
    Act like :class:`Generator`, except that for any subpart of the message
    passed to :meth:`Generator.flatten`, if the subpart is of main type
@@ -263,8 +264,7 @@
       "[Non-text (%(type)s) part of message omitted, filename %(filename)s]"
 
    Optional *_mangle_from_* and *maxheaderlen* are as with the
-   :class:`Generator` base class, except that the default value for
-   *maxheaderlen* is ``78`` (the RFC standard default header length).
+   :class:`Generator` base class.
 
 
 .. rubric:: Footnotes
diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst
--- a/Doc/whatsnew/3.6.rst
+++ b/Doc/whatsnew/3.6.rst
@@ -531,6 +531,9 @@
 The :mod:`email.mime` classes now all accept an optional *policy* keyword.
 (Contributed by Berker Peksag in :issue:`27331`.)
 
+The :class:`~email.generator.DecodedGenerator` now supports the *policy*
+keyword.
+
 
 encodings
 ---------
@@ -538,6 +541,7 @@
 On Windows, added the ``'oem'`` encoding to use ``CP_OEMCP`` and the ``'ansi'``
 alias for the existing ``'mbcs'`` encoding, which uses the ``CP_ACP`` code page.
 
+
 faulthandler
 ------------
 
diff --git a/Lib/email/generator.py b/Lib/email/generator.py
--- a/Lib/email/generator.py
+++ b/Lib/email/generator.py
@@ -452,7 +452,8 @@
     Like the Generator base class, except that non-text parts are substituted
     with a format string representing the part.
     """
-    def __init__(self, outfp, mangle_from_=None, maxheaderlen=78, fmt=None):
+    def __init__(self, outfp, mangle_from_=None, maxheaderlen=None, fmt=None, *,
+                 policy=None):
         """Like Generator.__init__() except that an additional optional
         argument is allowed.
 
@@ -474,7 +475,8 @@
 
         [Non-text (%(type)s) part of message omitted, filename %(filename)s]
         """
-        Generator.__init__(self, outfp, mangle_from_, maxheaderlen)
+        Generator.__init__(self, outfp, mangle_from_, maxheaderlen,
+                           policy=policy)
         if fmt is None:
             self._fmt = _FMT
         else:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -103,6 +103,8 @@
 Library
 -------
 
+- email.generator.DecodedGenerator now supports the policy keyword.
+
 - Issue #28027: Remove undocumented modules from ``Lib/plat-*``: IN, CDROM,
   DLFCN, TYPES, CDIO, and STROPTS.
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list