From fb1a7bc907021a57d9556c52f762f101eb55b5c1 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Fri, 9 Aug 2013 16:17:00 -0400 Subject: #18600: In 3.3, as_string does not accept a policy keyword. Also, document the policy keyword that was added to Message in 3.3. --- Doc/library/email.message.rst | 10 ++++++++-- Doc/library/email.policy.rst | 10 ---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Doc/library/email.message.rst b/Doc/library/email.message.rst index 2c7be8b..2d07a0a 100644 --- a/Doc/library/email.message.rst +++ b/Doc/library/email.message.rst @@ -31,9 +31,15 @@ parameters, and for recursively walking over the object tree. Here are the methods of the :class:`Message` class: -.. class:: Message() +.. class:: Message(policy=compat32) - The constructor takes no arguments. + The *policy* argument determiens the :mod:`~email.policy` that will be used + to update the message model. The default value, :class:`compat32 + ` maintains backward compatibility with the + Python 3.2 version of the email package. For more information see the + :mod:`~email.policy` documentation. + + .. versionchanged:: 3.3 The *policy* keyword argument was added. .. method:: as_string(unixfrom=False, maxheaderlen=0) diff --git a/Doc/library/email.policy.rst b/Doc/library/email.policy.rst index 54ebb1c..99806ee 100644 --- a/Doc/library/email.policy.rst +++ b/Doc/library/email.policy.rst @@ -97,16 +97,6 @@ correct line separator characters when creating the binary string to feed into ``sendmail's`` ``stdin``, where the default policy would use ``\n`` line separators. -Some email package methods accept a *policy* keyword argument, allowing the -policy to be overridden for that method. For example, the following code uses -the :meth:`~email.message.Message.as_string` method of the *msg* object from -the previous example and writes the message to a file using the native line -separators for the platform on which it is running:: - - >>> import os - >>> with open('converted.txt', 'wb') as f: - ... f.write(msg.as_string(policy=msg.policy.clone(linesep=os.linesep))) - Policy objects can also be combined using the addition operator, producing a policy object whose settings are a combination of the non-default values of the summed objects:: -- cgit v0.12