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

gh-89653: PEP 670: Functions don't cast pointers #91697

Merged
merged 2 commits into from
Apr 25, 2022
Merged

gh-89653: PEP 670: Functions don't cast pointers #91697

merged 2 commits into from
Apr 25, 2022

Conversation

vstinner
Copy link
Member

In the limited C API version 3.11 and newer, the following functions
no longer cast their object pointer argument with _PyObject_CAST() or
_PyObject_CAST_CONST():

  • Py_REFCNT(), Py_TYPE(), Py_SIZE()
  • Py_SET_REFCNT(), Py_SET_TYPE(), Py_SET_SIZE()
  • Py_IS_TYPE()
  • Py_INCREF(), Py_DECREF()
  • Py_XINCREF(), Py_XDECREF()
  • Py_NewRef(), Py_XNewRef()
  • PyObject_TypeCheck()
  • PyType_Check()
  • PyType_CheckExact()

Split Py_DECREF() implementation in 3 versions to make the code more
readable.

Update the xxlimited.c extension, which uses the limited C API
version 3.11, to pass PyObject* to these functions.

@vstinner
Copy link
Member Author

@erlend-aasland: I'm not sure about this change, so I created a draft PR. It's a part of the PEP 670 implementation.

@vstinner
Copy link
Member Author

See also #91768

In the limited C API version 3.11 and newer, the following functions
no longer cast their object pointer argument with _PyObject_CAST() or
_PyObject_CAST_CONST():

* Py_REFCNT(), Py_TYPE(), Py_SIZE()
* Py_SET_REFCNT(), Py_SET_TYPE(), Py_SET_SIZE()
* Py_IS_TYPE()
* Py_INCREF(), Py_DECREF()
* Py_XINCREF(), Py_XDECREF()
* Py_NewRef(), Py_XNewRef()
* PyObject_TypeCheck()
* PyType_Check()
* PyType_CheckExact()

Split Py_DECREF() implementation in 3 versions to make the code more
readable.

Update the xxlimited.c extension, which uses the limited C API
version 3.11, to pass PyObject* to these functions.
@vstinner vstinner marked this pull request as ready for review April 21, 2022 21:29
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