⚡ Sangsakala Proxy 🏠 Home
Skip to content

gh-61707: Clarify that Header.__str__() does not decode RFC 2047 encoded words - #161268

Open
ArtyomSimitian wants to merge 3 commits into
python:mainfrom
ArtyomSimitian:gh-61707-header-str-docs
Open

ArtyomSimitian wants to merge 3 commits into
python:mainfrom
ArtyomSimitian:gh-61707-header-str-docs

Conversation

@ArtyomSimitian

@ArtyomSimitian ArtyomSimitian commented Nov 3, 2026 •

Copy link
Copy Markdown

The docs for Header.__str__() say that all pieces are decoded, which suggests
that str(Header(s)) decodes RFC 2047 encoded words in s. It doesn't:

>>> from email.header import Header, decode_header, make_header
>>> str(Header('=?utf-8?q?Caf=C3=A9?='))
'=?utf-8?q?Caf=C3=A9?='
>>> str(make_header(decode_header('=?utf-8?q?Caf=C3=A9?=')))
'Café'

This adds a paragraph to the __str__() docs saying so, with an example
that points to decode_header() and make_header() for decoding raw
header strings.

An earlier PR for this issue (#31765) was closed without being merged. It
pointed readers to email.policy.default; this PR adds that pointer here too.

@ArtyomSimitian
ArtyomSimitian requested a review from a team as a code owner November 3, 2026 20:16
@python-cla-bot

python-cla-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@read-the-docs-community

read-the-docs-community Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #35624842 | 📁 Comparing bb7f8a3 against main (069aac9)

  🔍 Preview build  

2 files changed
± library/email.header.html
± whatsnew/changelog.html

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

Labels

awaiting review docs Documentation in the Doc dir

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant