René's URL Explorer Experiment


Title: gh-142006: Fix HeaderWriteError in email.policy.default caused by extra newline by pareshjoshij · Pull Request #142008 · python/cpython · GitHub

Open Graph Title: gh-142006: Fix HeaderWriteError in email.policy.default caused by extra newline by pareshjoshij · Pull Request #142008 · python/cpython

X Title: gh-142006: Fix HeaderWriteError in email.policy.default caused by extra newline by pareshjoshij · Pull Request #142008 · python/cpython

Description: Description This PR fixes gh-142006 where email.policy.default would raise a HeaderWriteError 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 contained only 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 test test_fold_address_list_with_stolen_whitespace to Lib/test/test_email/test_policy.py which reproduces the reported crash and verifies the fix. Linked Issue Fixes gh-142006

Open Graph Description: Description This PR fixes gh-142006 where email.policy.default would raise a HeaderWriteError when folding certain long address headers. The Issue: In _header_value_parser.py, the function _steal_t...

X Description: Description This PR fixes gh-142006 where email.policy.default would raise a HeaderWriteError when folding certain long address headers. The Issue: In _header_value_parser.py, the function _steal_t...

Opengraph URL: https://github.com/python/cpython/pull/142008

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/checks(.:format)
route-controllerpull_requests
route-actionchecks
fetch-noncev2:9f467090-5a5b-6331-5e44-9b4575b79e45
current-catalog-service-hash87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a
request-idA09E:179801:30E4EB5:4026EB7:696DB922
html-safe-nonceee78379a48a2905a5be05ffa1d9e857fefb9acd6555f769402b54c25db87d0d4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDlFOjE3OTgwMTozMEU0RUI1OjQwMjZFQjc6Njk2REI5MjIiLCJ2aXNpdG9yX2lkIjoiMzU1MDk4NzgxODYwMDYxMDA4MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac66b6d3dcc33dcd83b3d4fef0fd47321e081a36c201396d7bb69d8a0320960376
hovercard-subject-tagpull_request:3050476249
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/checks
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/142008/checks
twitter:imagehttps://avatars.githubusercontent.com/u/194076591?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/194076591?s=400&v=4
og:image:altDescription This PR fixes gh-142006 where email.policy.default would raise a HeaderWriteError when folding certain long address headers. The Issue: In _header_value_parser.py, the function _steal_t...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4922b452d03cd8dbce479d866a11bc25b59ef6ee2da23aa9b0ddefa6bd4d0064
turbo-cache-controlno-cache
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width full-width-p-0
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7e5ae23c70136152637ceee8d6faceb35596ec46
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/142008/checks#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F142008%2Fchecks
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F142008%2Fchecks
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fchecks&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/142008/checks
Reloadhttps://github.com/python/cpython/pull/142008/checks
Reloadhttps://github.com/python/cpython/pull/142008/checks
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/142008/checks
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/pull/142008/checks
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
bitdancerhttps://github.com/bitdancer
python:mainhttps://github.com/python/cpython/tree/main
pareshjoshij:fix-gh-142006https://github.com/pareshjoshij/cpython/tree/fix-gh-142006
Conversation 20 https://github.com/python/cpython/pull/142008
Commits 5 https://github.com/python/cpython/pull/142008/commits
Checks 60 https://github.com/python/cpython/pull/142008/checks
Files changed https://github.com/python/cpython/pull/142008/files
Please reload this pagehttps://github.com/python/cpython/pull/142008/checks
Please reload this pagehttps://github.com/python/cpython/pull/142008/checks
Sign in for the full log viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F142008%2Fchecks
gh-142006: Fix HeaderWriteError in email.policy.default caused by extra newline https://github.com/python/cpython/pull/142008/checks#top
Please reload this pagehttps://github.com/python/cpython/pull/142008/checks
Check labels on: pull_request https://github.com/python/cpython/actions/runs/19981319390
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/19981319390/job/57308145915?pr=142008
Unresolved review https://github.com/python/cpython/actions/runs/19981319390/job/57308145917?pr=142008
Lint on: pull_request https://github.com/python/cpython/actions/runs/19981319392
lint https://github.com/python/cpython/actions/runs/19981319392/job/57308145969?pr=142008
Tests on: pull_request https://github.com/python/cpython/actions/runs/19981319406
Change detection / Create context from changed files https://github.com/python/cpython/actions/runs/19981319406/job/57308146002?pr=142008
Docs / Docs https://github.com/python/cpython/actions/runs/19981319406/job/57308155515?pr=142008
Docs / Doctest https://github.com/python/cpython/actions/runs/19981319406/job/57308155507?pr=142008
Docs / Check EPUB https://github.com/python/cpython/actions/runs/19981319406/job/57308155508?pr=142008
Check if Autoconf files are up to date https://github.com/python/cpython/actions/runs/19981319406/job/57308154723?pr=142008
Check if generated files are up to date https://github.com/python/cpython/actions/runs/19981319406/job/57308154737?pr=142008
Windows / Build and test (x64) https://github.com/python/cpython/actions/runs/19981319406/job/57308155344?pr=142008
Windows (free-threading) / Build and test (x64) https://github.com/python/cpython/actions/runs/19981319406/job/57308155350?pr=142008
Windows / Build and test (Win32) https://github.com/python/cpython/actions/runs/19981319406/job/57308155314?pr=142008
Windows / Build and test (arm64) https://github.com/python/cpython/actions/runs/19981319406/job/57308155326?pr=142008
Windows (free-threading) / Build and test (arm64) https://github.com/python/cpython/actions/runs/19981319406/job/57308155342?pr=142008
Windows MSI${{ '' }} https://github.com/python/cpython/actions/runs/19981319406/job/57308154714?pr=142008
macOS / build and test (macos-14) https://github.com/python/cpython/actions/runs/19981319406/job/57308155296?pr=142008
macOS (free-threading) / build and test (macos-14) https://github.com/python/cpython/actions/runs/19981319406/job/57308155284?pr=142008
macOS / build and test (macos-15-intel) https://github.com/python/cpython/actions/runs/19981319406/job/57308155294?pr=142008
Ubuntu / build and test (ubuntu-24.04) https://github.com/python/cpython/actions/runs/19981319406/job/57308155373?pr=142008
Ubuntu / build and test (ubuntu-24.04-arm) https://github.com/python/cpython/actions/runs/19981319406/job/57308155379?pr=142008
Ubuntu (free-threading) / build and test (ubuntu-24.04) https://github.com/python/cpython/actions/runs/19981319406/job/57308155383?pr=142008
Ubuntu (free-threading) / build and test (ubuntu-24.04-arm) https://github.com/python/cpython/actions/runs/19981319406/job/57308155442?pr=142008
Ubuntu (bolt) / build and test (ubuntu-24.04) https://github.com/python/cpython/actions/runs/19981319406/job/57308155361?pr=142008
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 1.1.1w) https://github.com/python/cpython/actions/runs/19981319406/job/57308154767?pr=142008
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.0.18) https://github.com/python/cpython/actions/runs/19981319406/job/57308154760?pr=142008
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.2.6) https://github.com/python/cpython/actions/runs/19981319406/job/57308154776?pr=142008
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.3.5) https://github.com/python/cpython/actions/runs/19981319406/job/57308154780?pr=142008
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.4.3) https://github.com/python/cpython/actions/runs/19981319406/job/57308154787?pr=142008
Ubuntu SSL tests with OpenSSL (ubuntu-24.04, 3.5.4) https://github.com/python/cpython/actions/runs/19981319406/job/57308154784?pr=142008
Ubuntu SSL tests with AWS-LC (ubuntu-24.04, 1.55.0) https://github.com/python/cpython/actions/runs/19981319406/job/57308154738?pr=142008
Android (aarch64) https://github.com/python/cpython/actions/runs/19981319406/job/57308154785?pr=142008
Android (x86_64) https://github.com/python/cpython/actions/runs/19981319406/job/57308154794?pr=142008
iOS https://github.com/python/cpython/actions/runs/19981319406/job/57308154746?pr=142008
WASI / build and test https://github.com/python/cpython/actions/runs/19981319406/job/57308155020?pr=142008
Hypothesis tests on Ubuntu https://github.com/python/cpython/actions/runs/19981319406/job/57308154781?pr=142008
Address sanitizer (ubuntu-24.04) https://github.com/python/cpython/actions/runs/19981319406/job/57308154800?pr=142008
Sanitizers / TSan https://github.com/python/cpython/actions/runs/19981319406/job/57308155596?pr=142008
Sanitizers / TSan (free-threading) https://github.com/python/cpython/actions/runs/19981319406/job/57308155615?pr=142008
Sanitizers / UBSan https://github.com/python/cpython/actions/runs/19981319406/job/57308155605?pr=142008
Cross build Linux https://github.com/python/cpython/actions/runs/19981319406/job/57308154875?pr=142008
CIFuzz https://github.com/python/cpython/actions/runs/19981319406/job/57308154846?pr=142008
All required checks pass https://github.com/python/cpython/actions/runs/19981319406/job/57309050912?pr=142008
Check labels on: pull_request https://github.com/python/cpython/actions/runs/19981512533
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/19981512533/job/57308631420?pr=142008
Unresolved review https://github.com/python/cpython/actions/runs/19981512533/job/57308631417?pr=142008
Check labels on: pull_request https://github.com/python/cpython/actions/runs/19981512539
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/19981512539/job/57308631407?pr=142008
Unresolved review https://github.com/python/cpython/actions/runs/19981512539/job/57308631410?pr=142008
Check labels on: pull_request https://github.com/python/cpython/actions/runs/19994115969
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/19994115969/job/57339103894?pr=142008
Unresolved review https://github.com/python/cpython/actions/runs/19994115969/job/57339103898?pr=142008
Check labels on: pull_request https://github.com/python/cpython/actions/runs/19994116029
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/19994116029/job/57339103975?pr=142008
Unresolved review https://github.com/python/cpython/actions/runs/19994116029/job/57339103967?pr=142008
Check labels on: pull_request https://github.com/python/cpython/actions/runs/19994120869
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/19994120869/job/57339115899?pr=142008
Unresolved review https://github.com/python/cpython/actions/runs/19994120869/job/57339115908?pr=142008
Check labels on: pull_request https://github.com/python/cpython/actions/runs/19994120887
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/19994120887/job/57339115880?pr=142008
Unresolved review https://github.com/python/cpython/actions/runs/19994120887/job/57339115877?pr=142008
Check labels on: pull_request https://github.com/python/cpython/actions/runs/19994179586
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/19994179586/job/57339260538?pr=142008
Unresolved review https://github.com/python/cpython/actions/runs/19994179586/job/57339260523?pr=142008
Check labels on: pull_request https://github.com/python/cpython/actions/runs/19994180862
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/19994180862/job/57339264166?pr=142008
Unresolved review https://github.com/python/cpython/actions/runs/19994180862/job/57339264173?pr=142008
Check labels on: pull_request https://github.com/python/cpython/actions/runs/19994181538
DO-NOT-MERGE https://github.com/python/cpython/actions/runs/19994181538/job/57339265841?pr=142008
Unresolved review https://github.com/python/cpython/actions/runs/19994181538/job/57339265843?pr=142008
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.