Skip to content

gh-123961: Improve curses C API cleanup #124907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 3, 2024

Conversation

picnixz
Copy link
Member

@picnixz picnixz commented Oct 2, 2024

This PR moves some functions closer to where they are needed and adds the traversal and clear functions in prepartion to make the window type a heap type.

Note

I always hated dealing with void pointers so I'm grateful if you carefully check that I didn't introduce some decaying calls or weird stuff. In addition, please check that the names were carefully refactored (the functions look all the same and it's very simple to make typos!).

@picnixz picnixz changed the title Improve curses C API cleanup gh-123961: Improve curses C API cleanup Oct 2, 2024
@picnixz picnixz requested a review from vstinner October 2, 2024 15:21
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

I don't think that traverse() and clear() methods make sense before window_type becomes a heap type.

@picnixz
Copy link
Member Author

picnixz commented Oct 2, 2024

I don't think that traverse() and clear() methods make sense before window_type becomes a heap type.

No you're right but I think it would reduce the diff later. At runtime, they will be unused since the type is not a heap type (so they won't even be called). Whenever a new capsule is created, we just have the check that would be effective at runtime.

if (_PyType_HasFeature(_PyType_CAST(window_type), Py_TPFLAGS_HEAPTYPE)) {

But if you prefer to have it in the PR which moves it to a heap type, I can do it.

@picnixz
Copy link
Member Author

picnixz commented Oct 2, 2024

Since I don't know when I'll move it to heap types, I'll delay their addition until then.

@picnixz picnixz requested a review from vstinner October 3, 2024 07:27
@picnixz picnixz requested a review from vstinner October 3, 2024 10:25
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@vstinner vstinner enabled auto-merge (squash) October 3, 2024 10:34
@vstinner vstinner merged commit e6dd71d into python:main Oct 3, 2024
37 checks passed
@picnixz picnixz deleted the curses/better-capsule-123961 branch October 3, 2024 10:49
@vstinner
Copy link
Member

vstinner commented Oct 3, 2024

Merged, thanks.

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