Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33
Add PyUnstable_TryIncref and PyUnstable_EnableTryIncRef.#159
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
tests/test_pythoncapi_compat_cext.c Outdated
| return-1; | ||
| } | ||
| #endif | ||
| MyType.tp_name="MyType"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can you please use a less generic name, such asTryIncrefType? (for the variable name and the type name)
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
vstinner commentedNov 5, 2025
I'm fine with adding these two functions. I just have some suggestions on the implementation. |
Co-authored-by: Victor Stinner <vstinner@python.org>
tests/test_pythoncapi_compat_cext.c Outdated
| staticintMyObject_dealloc_called=0; | ||
| staticvoid | ||
| MyObject_dealloc(PyObject*op) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Would you mind to rename it toTryIncref_dealloc() and rename alsoMyObject_dealloc_called?
c44469c intopython:mainUh oh!
There was an error while loading.Please reload this page.
vstinner commentedNov 5, 2025
Merged, thanks for your contribution. |
These would be useful in PyTorch, which uses pythoncapi-compat.h. They are also already used inpybind11, which doesn't use pythoncapi-compat.h.