Crash when deleting decimal.Context.rounding through the descriptor
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with decimal.Context.rounding.delete and trace the descriptor path through context_setround(), getround(), and context_setattr(). Compare deletion behavior across rounding, prec, Emin, Emax, capitals, and clamp; done means descriptor deletion no longer crashes or raises an unintended SystemError. Linked PR gh-156807 indicates the work is already underway.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100