-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-121542: Document trailing newline behavior in set_content()
#121543
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This behavior is only present in the default content manager, Moreover, I'd suggest explicitly clarifying that such normalization applies only to msg.set_content(b'hello', 'text', 'plain', cte='quoted-printable', params={'charset': 'utf-8'}) then the binary string would be encoded exactly. |
Update email.message.rst
Thanks to @rapidcow for the suggestion! |
The previous patch only illustrates this behavior with a very specific edge case, which IMO did not do a good job elucidating the present ambiguous documentation, if not worsening it by obscuring the true intention behind EOL canonicalization for messages of text/* types. This instead should address the more general case, abeit less concrete, which seems like a fair compromise, considering users who care about accurate representation of line endings will likely carefully study the documentation and be assured that this is an expected deviation from the legacy API, while those who do not are not befuddled by a footnote that seems to warn of something out of the blue. I do not know if this is true to the original author's intention, but it is my personal understanding of this implementation at least. :/ The case of bytes is also addressed briefly in a subsequent bullet point to assure the user that it is to be expected that all bytes are preserved as any arbitrary binary file ought to be. I wish I could state this more explicitly, but that seems rather hard without presumably restructuring this particular page, so I will leave it to the original author... :) Signed-off-by: Yizheng Meng <[email protected]>
Actually, I stared at this for a while - I still think it could have been written better. It feels out of place when the rest of the body describing This time I wrote up a patch for what I have in mind though. I pushed it to GitHub in this fork I made of your fork. Would it be fine if I made a PR of your PR so you may perhaps consider merging in my patch, @ZeroIntensity? |
@rapidcow Sure, go ahead |
Okay! Can you check the pull request sometime?
I think I made it a while ago....
|
Sorry, GH didn't notify me for whatever reason. |
I forgot about this PR. @Eclips4 do you want to merge it, or should we get a second reviewer? |
Thanks @ZeroIntensity for the PR, and @Eclips4 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
pythonGH-121543) (cherry picked from commit fba475a) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Yizheng Meng <[email protected]>
pythonGH-121543) (cherry picked from commit fba475a) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Yizheng Meng <[email protected]>
GH-128995 is a backport of this pull request to the 3.13 branch. |
GH-128996 is a backport of this pull request to the 3.12 branch. |
…)` (GH-121543) (#128995) gh-121542: Document trailing newline behavior in `set_content()` (GH-121543) (cherry picked from commit fba475a) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Yizheng Meng <[email protected]>
…)` (GH-121543) (#128996) gh-121542: Document trailing newline behavior in `set_content()` (GH-121543) (cherry picked from commit fba475a) Co-authored-by: Peter Bierma <[email protected]> Co-authored-by: Yizheng Meng <[email protected]>
python#121543) Co-authored-by: Yizheng Meng <[email protected]>
set_content
andset_payload
#121542📚 Documentation preview 📚: https://cpython-previews--121543.org.readthedocs.build/