Skip to content

gh-146250: Fix memory leak in re-initialization of SyntaxError#146251

Open
bkap123 wants to merge 6 commits intopython:mainfrom
bkap123:syntax-error-leak
Open

gh-146250: Fix memory leak in re-initialization of SyntaxError#146251
bkap123 wants to merge 6 commits intopython:mainfrom
bkap123:syntax-error-leak

Conversation

@bkap123
Copy link
Contributor

@bkap123 bkap123 commented Mar 21, 2026

Added Py_XDECREF/Py_XSETREF to avoid a memory leak when calling SyntaxError.__init__.

Added `Py_XDECREF`/`Py_XSETREF` to avoid a memory leak when calling
`SyntaxError.__init__`.
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@picnixz
Copy link
Member

picnixz commented Mar 21, 2026

Sorry about the Py_CLEAR suggestion but I think creating new variables would be cleaner.

@bkap123
Copy link
Contributor Author

bkap123 commented Mar 21, 2026

What's wrong with using Py_CLEAR?

@picnixz
Copy link
Member

picnixz commented Mar 21, 2026

I think it is just better to hold temp vars and use XSETREF like in AttributeError.__init__

@picnixz
Copy link
Member

picnixz commented Mar 21, 2026

I will test the refleak bots so don't commit anything until they are done!

@picnixz picnixz added 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Mar 21, 2026
@bedevere-bot
Copy link

🤖 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.

@bedevere-bot bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants