Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-142006: Fix HeaderWriteError in email.policy.default caused by extra newline#142008

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
pareshjoshij wants to merge4 commits intopython:main
base:main
Choose a base branch
Loading
frompareshjoshij:fix-gh-142006

Conversation

@pareshjoshij
Copy link
Contributor

Description

This PR fixesgh-142006 whereemail.policy.default would raise aHeaderWriteError when folding certain long address headers.

The Issue:
In_header_value_parser.py, the function_steal_trailing_WSP_if_exists moves trailing whitespace from the previous line to the current one. However, if the previous line containedonly that whitespace, it was left as an empty string''. When joined, this resulted in a double newline (\n\n), which is illegal in headers and triggered the error.

The Fix:
Modified_steal_trailing_WSP_if_exists to remove the line entirely (lines.pop()) if it becomes empty after stealing the whitespace.

Verification:
Added a regression testtest_fold_address_list_with_stolen_whitespace toLib/test/test_email/test_policy.py which reproduces the reported crash and verifies the fix.

Linked Issue

Fixesgh-142006

fumiyas and pareshjoshij reacted with heart emoji
Copy link
Member

@bitdancerbitdancer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for finding and fixing this bug.

@bedevere-app
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phraseI have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@pareshjoshij
Copy link
ContributorAuthor

pareshjoshij commentedNov 28, 2025
edited
Loading

Thanks@bitdancer! I have made the requested changes; please review again.

  1. Updated the comment style in_header_value_parser.py.
  2. Moved the test totest__header_value_parser.py insideTestFolding, refactored to usemax_line_length, and switched to the file's nativeself._test style.
  3. Updated the NEWS entry text as suggested.

Please review again.

@pareshjoshij
Copy link
ContributorAuthor

I have made the requested changes; please review again.

I have made the requested changes; please review again.

@bedevere-app
Copy link

Thanks for making the requested changes!

@bitdancer: please review the changes made to this pull request.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@gaogaotiantiangaogaotiantianAwaiting requested review from gaogaotiantian

@bitdancerbitdancerAwaiting requested review from bitdancer

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

email.policy.default adds an extra newline char to email address headers and raises HeaderWriteError on stringify

2 participants

@pareshjoshij@bitdancer

[8]ページ先頭

©2009-2025 Movatter.jp