(original) (raw)

changeset: 85077:8fbaf4e649af branch: 3.3 parent: 85073:8b557ef46d7c user: R David Murray rdmurray@bitdance.com date: Fri Aug 09 16:17:00 2013 -0400 files: Doc/library/email.message.rst Doc/library/email.policy.rst description: #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. diff -r 8b557ef46d7c -r 8fbaf4e649af Doc/library/email.message.rst --- a/Doc/library/email.message.rst Thu Aug 08 20:12:28 2013 +0300 +++ b/Doc/library/email.message.rst Fri Aug 09 16:17:00 2013 -0400 @@ -31,9 +31,15 @@ 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 -r 8b557ef46d7c -r 8fbaf4e649af Doc/library/email.policy.rst --- a/Doc/library/email.policy.rst Thu Aug 08 20:12:28 2013 +0300 +++ b/Doc/library/email.policy.rst Fri Aug 09 16:17:00 2013 -0400 @@ -97,16 +97,6 @@ ``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::/rdmurray@bitdance.com