Title: decimal: `_decimal` casts the value of its `decimal_context` ContextVar without a type check · Issue #161387 · python/cpython · GitHub
Open Graph Title: decimal: `_decimal` casts the value of its `decimal_context` ContextVar without a type check · Issue #161387 · python/cpython
X Title: decimal: `_decimal` casts the value of its `decimal_context` ContextVar without a type check · Issue #161387 · python/cpython
Description: Bug report Summary Arithmetic on Decimal values crashes the interpreter if the decimal_context context variable has been set to something that isn't a decimal.Context. Expected: a TypeError when the variable does not hold a Context. Repr...
Open Graph Description: Bug report Summary Arithmetic on Decimal values crashes the interpreter if the decimal_context context variable has been set to something that isn't a decimal.Context. Expected: a TypeError when th...
X Description: Bug report Summary Arithmetic on Decimal values crashes the interpreter if the decimal_context context variable has been set to something that isn't a decimal.Context. Expected: a TypeError whe...
Opengraph URL: https://github.com/python/cpython/issues/161387
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"decimal: `_decimal` casts the value of its `decimal_context` ContextVar without a type check","articleBody":"### Bug report\n\n## Summary\nArithmetic on `Decimal` values crashes the interpreter if the `decimal_context` context variable has been set to something that isn't a `decimal.Context`.\n\nExpected: a `TypeError` when the variable does not hold a `Context`.\n\n## Reproducer\n\n```python\nimport contextvars\nimport decimal\n\ndecimal.getcontext() \nvar = next(v for v in contextvars.copy_context() if v.name == \"decimal_context\")\nvar.set(1)\ndecimal.Decimal(1) + decimal.Decimal(2)\n```\n\n```console\nSegmentation fault (core dumped)\n```\n\n### CPython versions tested on:\n\n3.15\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-161399\n* gh-161465\n* gh-161466\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/theosotr","@type":"Person","name":"theosotr"},"datePublished":"2026-11-05T08:09:48Z","url":"https://github.com/python/cpython/issues/161387"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5f417b37-1ff8-e732-3039-e2f4ec41c7ef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 98C2:F7C4C:3337F05:4493EC3:6B02026D |
| html-safe-nonce | b7e9eded535bebceb2b7d42d43ccacea7237f22ee12d2282c41d90fe3adef6c8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEMyOkY3QzRDOjMzMzdGMDU6NDQ5M0VDMzo2QjAyMDI2RCIsInZpc2l0b3JfaWQiOiI3MjExNDk3NjQ1MTA0MzAwNjUzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e6fa482fd1ef51e908f3ae783e6f873f0351ddc3345ed018314bde56ab9e379f |
| hovercard-subject-tag | issue:6219326898 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/161387/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8227647fce668e99057cf30b6829b073fb119b79e639b4a0ebbba4b3f11ca3ac/python/cpython/issues/161387 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8227647fce668e99057cf30b6829b073fb119b79e639b4a0ebbba4b3f11ca3ac/python/cpython/issues/161387 |
| og:image:alt | Bug report Summary Arithmetic on Decimal values crashes the interpreter if the decimal_context context variable has been set to something that isn't a decimal.Context. Expected: a TypeError when th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | theosotr |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width