Crash when deleting decimal.Context.rounding through the descriptor
还没有人认领这个 Issue。
评估
调研方向
从 decimal.Context.rounding.delete 开始,跟踪经过 context_setround()、getround() 和 context_setattr() 的 descriptor 路径。比较 rounding、prec、Emin、Emax、capitals 和 clamp 的删除行为;完成的标准是删除 descriptor 不再导致崩溃或引发非预期的 SystemError。关联的 PR gh-156807 表明这项工作已经在进行中。
由索引模型根据 Issue 内容生成。
描述
Crash report
What happened?
import decimal
decimal.Context.rounding.__delete__(decimal.Context())
Segmentation fault (core dumped)
context_setround() passes the value to getround(), which calls
PyUnicode_Check() on it without checking it for NULL, and the setter is
called with NULL when the attribute is deleted. Plain del ctx.rounding is
safe, because context_setattr() rejects deletion — but it is bypassed by
calling the descriptor.
The other five Context getsets do not crash, but raise SystemError:
import decimal
decimal.Context.prec.__delete__(decimal.Context())
# SystemError: ../Objects/longobject.c:577: bad argument to internal function
Same for Emin, Emax, capitals and clamp.
CPython versions tested on:
3.15, 3.14, 3.13, 3.12
Operating systems tested on:
Windows
Output from running 'python -VV' on the command line:
Python 3.12.3 (main, Jan 8 2026, 11:30:50) [GCC 13.3.0] / Python 3.14.2 (main, Dec 17 2025, 21:10:36) [MSC v.1944 64 bit (AMD64)]
Linked PRs
- gh-156807
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 558
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python/cpython 的其他 Issue
-
docs pending
难度 2/5 1-3 小时 新手友好度 78/100
-
stdlib type-feature
难度 2/5 1-3 小时 新手友好度 78/100
-
stdlib type-feature
难度 2/5 1-3 小时 新手友好度 72/100
-
build type-bug
难度 2/5 1-3 小时 新手友好度 76/100
-
stdlib topic-email type-feature
难度 2/5 1-3 小时 新手友好度 70/100
相似的 Issue
-
🐛 Bug 🔔 Pending processing
难度 2/5 1-3 小时 新手友好度 84/100
jumpserver/jumpserver#17584 ·
-
link-check link-check:sphinx-theme
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 90/100
modelscope/DiffSynth-Studio#1702 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
难度 2/5 1-3 小时 新手友好度 88/100
OpenHands/extensions#626 · 1 条评论 ·