Title: GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached · Issue #155752 · python/cpython · GitHub
Open Graph Title: GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached · Issue #155752 · python/cpython
X Title: GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached · Issue #155752 · python/cpython
Description: Crash report What happened? types.GenericAlias calculates its __parameters__ only when they are first needed, then caches the result on the alias. If an argument gains a __typing_subst__ attribute after the result has been cached, the ca...
Open Graph Description: Crash report What happened? types.GenericAlias calculates its __parameters__ only when they are first needed, then caches the result on the alias. If an argument gains a __typing_subst__ attribute ...
X Description: Crash report What happened? types.GenericAlias calculates its __parameters__ only when they are first needed, then caches the result on the alias. If an argument gains a __typing_subst__ attribute ...
Opengraph URL: https://github.com/python/cpython/issues/155752
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached","articleBody":"# Crash report\n\n### What happened?\n\n`types.GenericAlias` calculates its `__parameters__` only when they are first needed, then caches the result on the alias.\n\nIf an argument gains a `__typing_subst__` attribute after the result has been cached, the cached parameters no longer match the alias arguments. During a later substitution, `_Py_subs_parameters()` recognizes the changed argument as a parameter but cannot find it in the cached tuple, so tuple_index() returns -1.\n\nIn a debug build, this triggers a failed C assertion. In a release build, the -1 is used as an array index and can crash the process.\n\n```python\nclass Parameter:\n pass\n\nfirst = Parameter()\nfirst.__typing_subst__ = lambda value: value\nlate = Parameter()\n\nalias = dict[first, late]\nalias.__parameters__\nlate.__typing_subst__ = lambda value: value\nalias[0,]\n```\n\n### CPython versions tested on:\n\n3.15, 3.14, 3.13, 3.12, 3.11\n\n### Operating systems tested on:\n\nmacOS, Linux\n\n### Output from running 'python -VV' on the command line:\n\nPython 3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-155761\n* gh-155770\n* gh-155771\n* gh-155772\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/dariushoule","@type":"Person","name":"dariushoule"},"datePublished":"2026-08-13T19:37:28Z","url":"https://github.com/python/cpython/issues/155752"}
| 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:eea05ddc-851c-0e33-b670-e77db69ed47c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CB66:10531B:2B09353:370D3A2:6B01F32D |
| html-safe-nonce | 3460b82d27b7a03efbd0d20cda1feb68a2864a0afd521a1a39b5af2c86d0555b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQjY2OjEwNTMxQjoyQjA5MzUzOjM3MEQzQTI6NkIwMUYzMkQiLCJ2aXNpdG9yX2lkIjoiMjA4NjA1ODI5ODgzODIxNzUxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | aa7b5603dd455bed6619a12e5e0cfa45a071e70b0d9183f51fd761a17840096d |
| hovercard-subject-tag | issue:5145164585 |
| 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/155752/issue_layout |
| twitter:image | https://opengraph.githubassets.com/885c53ce5ff98c3d73df99386e4df72f5081b8825c434586dca632b1ec33ff52/python/cpython/issues/155752 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/885c53ce5ff98c3d73df99386e4df72f5081b8825c434586dca632b1ec33ff52/python/cpython/issues/155752 |
| og:image:alt | Crash report What happened? types.GenericAlias calculates its __parameters__ only when they are first needed, then caches the result on the alias. If an argument gains a __typing_subst__ attribute ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dariushoule |
| 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