Uh oh!
There was an error while loading. Please reload this page.
gh-146250: Fix memory leak in re-initialization of SyntaxError - #146251
Conversation
Added `Py_XDECREF`/`Py_XSETREF` to avoid a memory leak when calling `SyntaxError.__init__`.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: AN Long <aisk@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
picnixz
commented
Mar 21, 2026
Sorry about the Py_CLEAR suggestion but I think creating new variables would be cleaner. |
brijkapadia
commented
Mar 21, 2026
What's wrong with using |
picnixz
commented
Mar 21, 2026
I think it is just better to hold temp vars and use XSETREF like in |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
picnixz
commented
Mar 21, 2026
I will test the refleak bots so don't commit anything until they are done! |
bedevere-bot
commented
Mar 21, 2026
🤖 New build scheduled with the buildbot fleet by @picnixz for commit 22cff11 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F146251%2Fmerge If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again. |
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I confirm that the added test leaks without the fix, and doesn't leak with the fix.
Uh oh!
There was an error while loading. Please reload this page.
Thanks @bkap123 for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
pythonGH-146251) (cherry picked from commit 0de4e08) Co-authored-by: Brij Kapadia <97006829+bkap123@users.noreply.github.com>
Sorry, @bkap123 and @kumaraditya303, I could not cleanly backport this to |
GH-146517 is a backport of this pull request to the 3.14 branch. |
GH-146519 is a backport of this pull request to the 3.13 branch. |
…r` (GH-146251) (#146519) * [3.13] gh-146250: Fix memory leak in re-initialization of `SyntaxError` (GH-146251) (cherry picked from commit 0de4e08) Co-authored-by: Brij Kapadia <97006829+bkap123@users.noreply.github.com> * Minimize the changes * Minimize the changes * Minimize the changes --------- Co-authored-by: Brij Kapadia <97006829+bkap123@users.noreply.github.com>
Added
Py_XDECREF/Py_XSETREFto avoid a memory leak when callingSyntaxError.__init__.SyntaxError.__init__memory leak on re-initialization #146250