Skip to content

[3.14] gh-116946: fully implement GC protocol for _curses_panel.panel (GH-138333) - #138427

Merged
hugovk merged 1 commit into
python:3.14from
picnixz:backport-572df47-3.14
Sep 6, 2025
Merged

hugovk merged 1 commit into
python:3.14from
picnixz:backport-572df47-3.14

Conversation

@picnixz

@picnixz picnixz commented Sep 3, 2025 •

Copy link
Copy Markdown
Member

This commit fixes possible reference loops via panel.set_userptr by implementing tp_clear and tp_traverse for panel objects. (cherry picked from commit 572df47)

…l.panel` (pythonGH-138333)

This commit fixes possible reference loops via `panel.set_userptr`
by implementing `tp_clear` and `tp_traverse` for panel objects.
(cherry picked from commit 572df47)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. 👍

Comment thread Modules/_curses_panel.c
{
PyCursesPanelObject *po = PyObject_New(PyCursesPanelObject,
state->PyCursesPanel_Type);
assert(state != NULL);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These asserts are redundant. Dereferencing a NULL pointer has a similar effect to a failed assert.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I actually added those asserts for debugging purposes. Since they are on main, I think it's better to reduce the diff.

@hugovk
hugovk merged commit 9cc2b25 into python:3.14 Sep 6, 2025
@picnixz
picnixz deleted the backport-572df47-3.14 branch September 6, 2025 18:37
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull request Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants