Skip to content

[stdlib] Add PyCapsule_New and PyCapsule_GetPointer #4334

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

winding-lines
Copy link

These are critical when interacting with PyCapsules created by other libraries in the system. The current use case is interacting with PyArrow.

@winding-lines winding-lines requested a review from a team as a code owner April 11, 2025 01:26
@winding-lines winding-lines changed the title Add PyCapsule_New and PyCapsule_GetPointer [stdlib] Add PyCapsule_New and PyCapsule_GetPointer Apr 11, 2025
These are critical when interacting with PyCapsules created by other
libraries in the system. The current use case is interacting with
PyArrow.

Signed-off-by: Marius Seritan <[email protected]>
Comment on lines 1955 to 1957
return self.lib.call["PyCapsule_New", PyObjectPtr](
pointer, name.unsafe_ptr(), destructor
)
Copy link
Contributor

@soraros soraros Apr 11, 2025

Choose a reason for hiding this comment

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

I think you need to call self._inc_total_rc() here, since PyCapsule_New returns a new reference. Also, we should cast name to c_char, if only to document ABI compliance.

Copy link
Author

Choose a reason for hiding this comment

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

Oops, adding.

@soraros
Copy link
Contributor

soraros commented Apr 11, 2025

Could you please put improve the docstring a bit more and add the signature of the Python C API function in a comment #4205 style?

Signed-off-by: Marius Seritan <[email protected]>
@winding-lines
Copy link
Author

Could you please put improve the docstring a bit more and add the signature of the Python C API function in a comment #4205 style?

Could you please put improve the docstring a bit more and add the signature of the Python C API function in a comment #4205 style?

Nice, I pushed a second commit. I am not sure if you prefer separate commits for ease of review or just one commit for cleaner history.

soraros

This comment was marked as resolved.

@soraros
Copy link
Contributor

soraros commented Apr 11, 2025

Nice, I pushed a second commit. I am not sure if you prefer separate commits for ease of review or just one commit for cleaner history.

I think they get squashed when imported into their internal repo anyway, so it shouldn't matter much.

winding-lines and others added 5 commits April 11, 2025 06:06
@winding-lines
Copy link
Author

I think inline comments are important, as they help with eyeballing, especially when revisiting the code after a month.

Thanks for the edits, accepted them.

Signed-off-by: Marius Seritan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants