Skip to content
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

[WIP] bpo-42294: Add Py_SetRef() and Py_XSetRef() #23209

Closed
wants to merge 2 commits into from
Closed

[WIP] bpo-42294: Add Py_SetRef() and Py_XSetRef() #23209

wants to merge 2 commits into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Nov 9, 2020

Add Py_SetRef() and Py_XSetRef() functions to set a strong reference
to a new object without creating a temporary dangling pointer.

Rewrite the Py_SETREF() and Py_XSETREF() macros using respectively
Py_SetRef() and Py_XSetRef() functions.

Rewrite the Py_CLEAR() macro using the Py_XSetRef() public.

https://bugs.python.org/issue42294

Add Py_SetRef() and Py_XSetRef() functions to set a strong reference
to a new object without creating a temporary dangling pointer.

Rewrite the Py_SETREF() and Py_XSETREF() macros using respectively
Py_SetRef() and Py_XSetRef() functions.

Rewrite the Py_CLEAR() macro using the Py_XSetRef() public.
@vstinner
Copy link
Member Author

vstinner commented Nov 9, 2020

This change exposes Py_SETREF() and Py_XSETREF() macros as regular functions to allow using them in extension modules which cannot use the C preprocessor, like extensions written in Rust. It also adds Py_SetRef() and Py_XSetRef() as regular functions part of the limited C API and the stable ABI, whereas Py_SETREF() and Py_XSETREF() are excluded from the limited C API.

The Py_SETREF() and Py_XSETREF() macros were added in 2016 by @serhiy-storchaka in bpo-26200 with the commit 57a01d3.

@vstinner
Copy link
Member Author

vstinner commented Nov 9, 2020

cc @methane @serhiy-storchaka

@methane
Copy link
Member

methane commented Nov 10, 2020

I am not sure about this change really helps Rust, PyPy, HPy, etc.
Is this proposal based on some discussion in some forum?

@vstinner vstinner changed the title bpo-42294: Add Py_SetRef() and Py_XSetRef() [WIP] bpo-42294: Add Py_SetRef() and Py_XSetRef() Nov 11, 2020
@vstinner vstinner marked this pull request as draft November 11, 2020 00:46
@vstinner
Copy link
Member Author

I am not sure about this change really helps Rust, PyPy, HPy, etc.
Is this proposal based on some discussion in some forum?

There was no discussion about that. I prefer to convert this PR to a draft until I have more time to explain the overall rationale for https://bugs.python.org/issue42294

Also, Serhiy wrote that Py_SETREF() had some flaws, I didn't know that. I will have to dig into old discussions.

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Dec 16, 2020
@vstinner vstinner removed the stale Stale PR or inactive for long period of time. label Dec 16, 2020
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Jan 15, 2021
@vstinner
Copy link
Member Author

I close this PR since I failed to prove that it's useful for Rust, PyPy or HPy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants