Skip to content

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

Merged
vstinner merged 2 commits into
python:mainfrom
vstinner:dont_cast_api311
Apr 25, 2022
Merged

vstinner merged 2 commits into
python:mainfrom
vstinner:dont_cast_api311

Conversation

@vstinner

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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