types.MappingProxyType states that proxy[key] will throw a KeyError, but that is not always true
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Documentation
In the documentation, it states proxy[key] will:
Return the item of the underlying mapping with key key. Raises a KeyError if key is not in the underlying mapping.
https://docs.python.org/3/library/types.html#types.MappingProxyType
However, it is possible to get an AttributeError instead, and in fact, unit tests for the dataclasses module require this to be true (metadata in dataclasses.field is wrapped in a mapping proxy):
The unit tests above are from Python3.12.
Looks like the CPython source code only forwards the getitem call to the inner mapping:
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先查看連結的 Python 文件頁面中關於 MappingProxyType 的文件,然後將其措辭與所參照的 dataclasses 測試和 Objects/descrobject.c 實作進行比較。完成的標準是:文件準確描述測試和實作所呈現的例外行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 1/5
- 預估耗時
- 1 小時以內
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 58/100