mailbox: document Message vs EmailMessage situation

未關閉
#96,425 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
48/100
Issue 類型
文件
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
python
領域
documentation

研究方向

從 mailbox 模組文件開始,將其中對 email.Message 的參照與 email 套件中關於 EmailMessage 和 compat32 API 的文件進行比較。檢視 mailbox.Message、email.Message 與 email.message.EmailMessage 之間的關係,然後在 mailbox 文件中釐清它們各自的角色與移轉狀態。當文件說明應用程式應使用哪個類別,以及 mailbox 為什麼仍然公開舊版階層時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

docs

Documentation

If I read the email documentation, it makes a clear case for staying away from email.Message:

The foregoing represent the modern (unicode friendly) API of the email package. The remaining sections, starting with the Message class, cover the legacy compat32 API that deals much more directly with the details of how email messages are represented. The compat32 API does not hide the details of the RFCs from the application, but for applications that need to operate at that level, they can be useful tools. This documentation is also relevant for applications that are still using the compat32 API for backward compatibility reasons.

Changed in version 3.6: Docs reorganized and rewritten to promote the new EmailMessage/EmailPolicy API.

And indeed, there are common tasks that are hard to do in email.Message and easy with EmailMessage (see get_body() for a very common use case).

However in the documentation of mailbox, email.Message is mentioned like it's the standard.

Since at the moment in the standard library, with regards to email handling, the rule "There should be one-- and preferably only one --obvious way to do it." seems to be violated, and there are several classes with confusingly similar names but very different roles (mailbox.Message, email.Message, email.message.EmailMessage) it would help to have a clarification of the situation in the documentation of mailbox, at least until #77156 happens.

I don't know enough of the background that led to this situation to be able to draft a serious proposal for the documentation, but I guess something along the lines of this could be an initial draft:

There are currently two distinct classes for handling emails: email.Message (deprecated), and email.message.EmailMessage. The latter is more featureful and easier to use, but the mailbox module still has not been updated to transition to it.
mailbox subclasses the deprecated email.Message as mailbox.Message, to act as the base hierarchy for messages read from mailboxes.
It is expected that mailbox.Message will become a subclass of email.message.EmailMessage in a future version of Python [insert API compatibility notes].

主要語言
Python
星號
77.2k
分支
36k
平均合併
1 天 9 小時
30 天內合併 PR
558

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

python/cpython 的其他 Issue

查看 python/cpython 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。