Timedelta cannot be used in match statements
未關閉
還沒有人認領這個 Issue。
extension-modules
stdlib
type-feature
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
Timedelta cannot be evaluated in match statements, see example below
from datetime import timedelta
td = timedelta(hours=1)
print(td == timedelta(hours=1)) # evaluates to True
match td:
case timedelta(days=1):
print('day')
case timedelta(hours=1):
print('hour')
case _:
print('unhandled') # prints `unhandled`
CPython versions tested on:
3.11
Operating systems tested on:
macOS
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先,在 CPython 3.11 上重現所提供的 timedelta match 敘述,並將其行為與相等性進行比較。該 issue 沒有指出原始碼檔案或測試進入點,因此請追蹤類別模式如何處理 timedelta 屬性,並在找出適當的回歸測試之前,判斷預期的比對行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- compilers
- Issue 類型
- 缺陷
- 難度
- 5/5
- 預估耗時
- 一週以上
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100