Skip to content

gh-148263: Fix refcount leak in weakref proxy operations#148308

Draft
prakashsellathurai wants to merge 20 commits intopython:mainfrom
prakashsellathurai:fix/148263
Draft

gh-148263: Fix refcount leak in weakref proxy operations#148308
prakashsellathurai wants to merge 20 commits intopython:mainfrom
prakashsellathurai:fix/148263

Conversation

@prakashsellathurai
Copy link
Copy Markdown

@prakashsellathurai prakashsellathurai commented Apr 9, 2026

Validation:

Reproducer scripts -> https://gist.github.com/prakashsellathurai/ea7ba0ec8a5cf049881464d34de31411

before (mainline )

(venv) PS C:\Users\Prakash\Documents\work\projects\mainline> .\python.bat ..\cpython\tmp\final-test.py
Running Debug|x64 interpreter...
binary +: leaked 10003 refs (~1/call)
ternary pow: leaked 10003 refs (~1/call)
compare ==: leaked 10003 refs (~1/call)

After this change

(venv) PS C:\Users\Prakash\Documents\work\projects\cpython> .\python.bat  .\tmp\final-test.py
Running Debug|x64 interpreter...
binary +: leaked 3 refs (~0/call)
ternary pow: leaked 3 refs (~0/call)
compare ==: leaked 3 refs (~0/call)

@bedevere-app
Copy link
Copy Markdown

bedevere-app bot commented Apr 9, 2026

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.

Copy link
Copy Markdown
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

I would prefer that we keep a macro form to calls. In addition, please follow PEP-7.

@prakashsellathurai prakashsellathurai changed the title gh-148263: Fix UNWRAP ref leak with dead proxy gh-148263: Fix refcount leak in weakref proxy binary/ternary operations and proxy_richcompare Apr 12, 2026
@prakashsellathurai prakashsellathurai changed the title gh-148263: Fix refcount leak in weakref proxy binary/ternary operations and proxy_richcompare gh-148263: Fix refcount leak in weakref proxy operations Apr 12, 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.

2 participants