GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-155752: Do not crash when GenericAlias parameters change during substitution by dariushoule · Pull Request #155761 · python/cpython

Conversation

@dariushoule

@dariushoule dariushoule commented Aug 13, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #155752

_Py_subs_parameters() assumed that every argument with a __typing_subst__ attribute was present in the cached __parameters__ tuple. However, __typing_subst__ can be added to an argument after __parameters__ has been cached, causing the lookup to return -1, which is subsequently looked up.

Check the lookup result before indexing the substitution arguments and raise TypeError when the changed argument is not in __parameters__.

  • Issue: GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached #155752

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@dariushoule
pythongh-155752: Do not crash when GenericAlias parameters change dur…
7a1932e
…ing substitution

An alias argument can gain __typing_subst__ after __parameters__ has been cached, including during a preparation or substitution callback. Check that the argument is present before indexing the substitution arguments.
@dariushoule
dariushoule requested review from AlexWaygood and JelleZijlstra as code owners August 13, 2026 21:00
@python-cla-bot

python-cla-bot Bot commented Aug 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot mentioned this pull request Aug 13, 2026
GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached #155752
Closed
@bedevere-app bedevere-app Bot added the awaiting review label Aug 13, 2026
@JelleZijlstra JelleZijlstra added needs backport to 3.10 needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 bugs and security fixes labels Aug 13, 2026
JelleZijlstra
JelleZijlstra approved these changes Aug 13, 2026
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Aug 13, 2026
picnixz
picnixz reviewed Aug 13, 2026
View reviewed changes
Comment thread Lib/test/test_typing.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

picnixz
picnixz approved these changes Aug 13, 2026
View reviewed changes

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment is just a nitpick btw

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

dariushoule reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@dariushoule
Move issue comment
3c9c477
@JelleZijlstra
JelleZijlstra merged commit c0006fa into python:main Aug 14, 2026
98 of 100 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Aug 14, 2026

Copy link
Copy Markdown

Thanks @dariushoule for the PR, and @JelleZijlstra for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11, 3.12, 3.13, 3.14, 3.15.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Aug 14, 2026
@bedevere-app

bedevere-app Bot commented Aug 14, 2026

Copy link
Copy Markdown

GH-155770 is a backport of this pull request to the 3.15 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Aug 14, 2026
@bedevere-app

bedevere-app Bot commented Aug 14, 2026

Copy link
Copy Markdown

GH-155771 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 14, 2026
@miss-islington-app

miss-islington-app Bot commented Aug 14, 2026

Copy link
Copy Markdown

Sorry, @dariushoule and @JelleZijlstra, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker c0006faf4f48f01126a8a0752da8f159142e410d 3.12
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app miss-islington-app Bot assigned JelleZijlstra Aug 14, 2026
@bedevere-app

bedevere-app Bot commented Aug 14, 2026

Copy link
Copy Markdown

GH-155772 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app

miss-islington-app Bot commented Aug 14, 2026

Copy link
Copy Markdown

Sorry, @dariushoule and @JelleZijlstra, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker c0006faf4f48f01126a8a0752da8f159142e410d 3.11
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Aug 14, 2026
@miss-islington-app

miss-islington-app Bot commented Aug 14, 2026

Copy link
Copy Markdown

Sorry, @dariushoule and @JelleZijlstra, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker c0006faf4f48f01126a8a0752da8f159142e410d 3.10
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@BHUVANSH855

BHUVANSH855 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

@JelleZijlstra @picnixz
can I work on the backport PRs ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk pushed a commit that referenced this pull request Aug 14, 2026
@miss-islington @dariushoule
[3.15] gh-155752: Do not crash when GenericAlias parameters change du…
b8a9987
…ring substitution (GH-155761) (#155770)

gh-155752: Do not crash when GenericAlias parameters change during substitution (GH-155761)

An alias argument can gain __typing_subst__ after __parameters__ has been cached, including during a preparation or substitution callback. Check that the argument is present before indexing the substitution arguments.
(cherry picked from commit c0006fa)

Co-authored-by: Darius Houle <[email protected]>
mbeijen pushed a commit to mbeijen/cpython that referenced this pull request Aug 14, 2026
@dariushoule @mbeijen
pythongh-155752: Do not crash when GenericAlias parameters change dur…
1772486
…ing substitution (python#155761)

An alias argument can gain __typing_subst__ after __parameters__ has been cached, including during a preparation or substitution callback. Check that the argument is present before indexing the substitution arguments.
@StanFromIreland StanFromIreland removed needs backport to 3.10 needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Aug 16, 2026
@StanFromIreland

StanFromIreland commented Aug 16, 2026

Copy link
Copy Markdown
Member

I'm assuming they were added by accident so I've removed them, this seems like a regular bug to me.

BHUVANSH855 reacted with thumbs up emoji marksteward reacted with thumbs down emoji
All reactions
  • 👍 1 reaction
  • 👎 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AlexWaygood

AlexWaygood commented Aug 16, 2026

Copy link
Copy Markdown
Member

I think we usually backport crashes as far as we can since they can be security vulnerabilities; segfaults can corrupt memory, etc

marksteward reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@StanFromIreland

StanFromIreland commented Aug 16, 2026

Copy link
Copy Markdown
Member

I think we usually backport crashes as far as we can since they can be security vulnerabilities; segfaults can corrupt memory, etc

Under our security policy I don't see how this qualifies, I don't think a bug is a vulnerability simply because it causes a segfault. Vulnerabilities can be exploited, whereas this does not seem like something exploitable in code that may exist in the real world.

marksteward reacted with thumbs down emoji
All reactions
  • 👎 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

terryjreedy pushed a commit that referenced this pull request Sep 8, 2026
@miss-islington @dariushoule
[3.14] gh-155752: Do not crash when GenericAlias parameters change du…
96964c8
…ring substitution (GH-155761) (#155771)

gh-155752: Do not crash when GenericAlias parameters change during substitution (GH-155761)

An alias argument can gain __typing_subst__ after __parameters__ has been cached, including during a preparation or substitution callback. Check that the argument is present before indexing the substitution arguments.
(cherry picked from commit c0006fa)

Co-authored-by: Darius Houle <[email protected]>
terryjreedy pushed a commit that referenced this pull request Sep 8, 2026
@miss-islington @dariushoule
[3.13] gh-155752: Do not crash when GenericAlias parameters change du…
649e421
…ring substitution (GH-155761) (#155772)

gh-155752: Do not crash when GenericAlias parameters change during substitution (GH-155761)

An alias argument can gain __typing_subst__ after __parameters__ has been cached, including during a preparation or substitution callback. Check that the argument is present before indexing the substitution arguments.
(cherry picked from commit c0006fa)

Co-authored-by: Darius Houle <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@picnixz picnixz picnixz approved these changes
@AlexWaygood AlexWaygood Awaiting requested review from AlexWaygood AlexWaygood is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@JelleZijlstra JelleZijlstra

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@dariushoule @BHUVANSH855 @StanFromIreland @AlexWaygood @JelleZijlstra @picnixz
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.