-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Conversation
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.
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. |
I am not sure about this change really helps Rust, PyPy, HPy, etc. |
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. |
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 |
This PR is stale because it has been open for 30 days with no activity. |
I close this PR since I failed to prove that it's useful for Rust, PyPy or HPy. |
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