diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-08-09 20:15:28 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-08-09 20:15:28 (GMT) |
commit | bb17d2b857d33e474f830c4a665f1fa412eb29f1 (patch) | |
tree | 6abcd65ca409e435a0a0b4b7184c3a2318402e3e /Doc/whatsnew | |
parent | 3f58277382f3e337d225da547bdb26bc555570a4 (diff) | |
download | cpython-bb17d2b857d33e474f830c4a665f1fa412eb29f1.zip cpython-bb17d2b857d33e474f830c4a665f1fa412eb29f1.tar.gz cpython-bb17d2b857d33e474f830c4a665f1fa412eb29f1.tar.bz2 |
#18600: add policy to add_string, and as_bytes and __bytes__ methods.
This was triggered by wanting to make the doctest in email.policy.rst pass;
as_bytes and __bytes__ are clearly useful now that we have BytesGenerator.
Also updated the Message docs to document the policy keyword that was
added in 3.3.
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r-- | Doc/whatsnew/3.4.rst | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst index 80b4b01..6011f8e 100644 --- a/Doc/whatsnew/3.4.rst +++ b/Doc/whatsnew/3.4.rst @@ -195,6 +195,26 @@ The :meth:`~aifc.getparams` method now returns a namedtuple rather than a plain tuple. (Contributed by Claudiu Popa in :issue:`17818`.) +email +----- + +:meth:`~email.message.Message.as_string` now accepts a *policy* argument to +override the default policy of the message when generating a string +representation of it. This means that ``as_string`` can now be used in more +circumstances, instead of having to create and use a :mod:`~email.generator` in +order to pass formatting parameters to its ``flatten`` method. + +New method :meth:`~email.message.Message.as_bytes` added to produce a bytes +representation of the message in a fashion similar to how ``as_string`` +produces a string representation. It does not accept the *maxheaderlen* +argument, but does accept the *unixfrom* and *policy* arguments. The +:class:`~email.message.Message` :meth:`~email.message.Message.__bytes__` method +calls it, meaning that ``bytes(mymsg)`` will now produce the intuitive +result: a bytes object containing the fully formatted message. + +(Contributed by R. David Murray in :issue:`18600`.) + + functools --------- |