Skip to content

gh-161767: Fix refleak in PyDict_AsFrozenDictAndClear() - #162250

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:fix_asfrozendict_leak
Nov 19, 2026
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:fix_asfrozendict_leak

Conversation

@vstinner

@vstinner vstinner commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Py_DECREF() the frozendict if transfer_keys_and_values_lock_held() fails.

Py_DECREF() the frozendict if transfer_keys_and_values_lock_held()
fails.
@vstinner

Copy link
Copy Markdown
Member Author

./python -m test test_capi.test_dict -R 3:3 leaks test_capi.test_dict leaked [4, 4, 4] references, sum=12 on the main branch.

With this change, it no longer leaks.

@vstinner
vstinner merged commit aced381 into python:main Nov 19, 2026
62 checks passed
@vstinner
vstinner deleted the fix_asfrozendict_leak branch November 19, 2026 00:55
@vstinner

Copy link
Copy Markdown
Member Author

Merged. Thanks for the review @sobolevn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants