Skip to content

gh-157621: Clear weakrefs for ParamSpec attributes - #157622

Merged
JelleZijlstra merged 3 commits into
python:mainfrom
GruffElixir:fix-157621-paramspecattr-weakrefs
Sep 17, 2026
Merged

JelleZijlstra merged 3 commits into
python:mainfrom
GruffElixir:fix-157621-paramspecattr-weakrefs

Conversation

@GruffElixir

@GruffElixir GruffElixir commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #157621.

ParamSpec.args and .kwargs use paramspecattr_dealloc, which freed the instance without clearing its weakrefs. Clear them before freeing the object, matching the other type-parameter deallocators.

Adds a regression test for both attributes that checks the weakref callback runs and the reference is cleared.

Validation:

  • PCbuild/build.bat -d -q
  • PCbuild/amd64/python_d.exe -m test -v test_typing (742 tests)

Copilot AI lite review requested due to automatic review settings September 16, 2026 14:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bedevere-app

bedevere-app Bot commented Sep 16, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app

bedevere-app Bot commented Sep 16, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@AlexWaygood
AlexWaygood removed their request for review September 16, 2026 14:10
@JelleZijlstra JelleZijlstra added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 17, 2026
@JelleZijlstra
JelleZijlstra enabled auto-merge (squash) September 17, 2026 02:48
@JelleZijlstra
JelleZijlstra merged commit b215552 into python:main Sep 17, 2026
60 checks passed
@miss-islington-app

Copy link
Copy Markdown

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

@bedevere-app

bedevere-app Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 17, 2026
@bedevere-app

bedevere-app Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 17, 2026
@bedevere-app

bedevere-app Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash in clear_weakref() for ParamSpecArgs/ParamSpecKwargs

3 participants