[issue18600] email.policy doc example passes 'policy' to as_string, but that doesn't work
New submission from R. David Murray:
When I wrote those docs I intended to add a policy argument to as_string, but did not do it by the time 3.3 was released. The docs for 3.3 need to be corrected, and I need to decide if I do want to add that keyword to as_string in 3.4 (the answer is probably yes, but I may check with the email-sig first).
----------
assignee: docs@python
components: Documentation, email
messages: 193937
nosy: barry, docs@python, r.david.murray
priority: normal
severity: normal
stage: needs patch
status: open
title: email.policy doc example passes 'policy' to as_string, but that doesn't work
type: behavior
versions: Python 3.3, Python 3.4
_______________________________________
Python tracker
R. David Murray added the comment:
Turns out even with as_string accepting a policy keyword, the example still failed. It needs to be generating a bytes object, not a string. Before I even realized that, though, I decided I wanted to add as_bytes (and __bytes__). So the attached patch does that: adds policy to as_string, and adds new methods as_bytes and __bytes__ to Message.
This patch is only for 3.4. The 3.3 patch will just delete that part of the policy example, so I'm not going to bother to upload it.
----------
keywords: +patch
stage: needs patch -> patch review
Added file: http://bugs.python.org/file31209/as_string_policy.patch
_______________________________________
Python tracker
Roundup Robot added the comment:
New changeset 53287858e71f by R David Murray in branch 'default':
#18600: add policy to add_string, and as_bytes and __bytes__ methods.
http://hg.python.org/cpython/rev/53287858e71f
New changeset 8fbaf4e649af by R David Murray in branch '3.3':
#18600: In 3.3, as_string does not accept a policy keyword.
http://hg.python.org/cpython/rev/8fbaf4e649af
New changeset b9a5b7e3b32f by R David Murray in branch 'default':
Null merge related to #18600.
http://hg.python.org/cpython/rev/b9a5b7e3b32f
----------
nosy: +python-dev
_______________________________________
Python tracker
R. David Murray added the comment:
Committed with changes pointed out by Antoine (thank you Antoine).
----------
resolution: -> fixed
stage: patch review -> committed/rejected
status: open -> closed
_______________________________________
Python tracker
participants (2)
-
R. David Murray
-
Roundup Robot