typing._allow_reckless_class_checks doesn't work when _abc doesn't exist.
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
When typing._caller's sys._getframe fallback is triggered without _abc module, _typing._allow_reckless_class_checks fails to check _py_abc while running abc.ABCMeta.__instancecheck__.
Without _abc module, _typing._allow_reckless_class_checksfails to check _py_abc
Related code in typing.py:
https://github.com/python/cpython/blob/v3.14.0b3/Lib/typing.py#L1846-L1863
This is technically a bug of typing.py, but really hard to be triggered on CPython.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Solution suggestion
Patch typing._allow_reckless_class_checks to also check _py_abc
This is the most conservative approach. Compatible with all of previous scenarios and additionally fixing the bug.
Patch typing._caller to remove sys._getframe or raise warning when fallback
If the the typing requires to work with sys._getframemodulename, then let the users to know it has a caveat.
Linked PRs
- gh-136115
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
閱讀 Lib/typing.py 的第 1846-1863 行,並將提議的變更與連結的 PR gh-136115 進行比較。當 _abc 無法使用時,_allow_reckless_class_checks 也能處理 _py_abc,且已在 CPython main 分支上驗證其行為,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100