diff options
author | Neil Schemenauer <nas-github@arctrix.com> | 2024-12-03 18:33:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-03 18:33:06 (GMT) |
commit | fc5a0dc22483a35068888e828c65796d7a792c14 (patch) | |
tree | f3c92006e7f12df9515e20346d31abe01c21c800 /Doc | |
parent | 276cd66ccbbf85996a57bd1db3dd29b93a6eab64 (diff) | |
download | cpython-fc5a0dc22483a35068888e828c65796d7a792c14.zip cpython-fc5a0dc22483a35068888e828c65796d7a792c14.tar.gz cpython-fc5a0dc22483a35068888e828c65796d7a792c14.tar.bz2 |
gh-127271: Replace use of PyCell_GET/SET (gh-127272)
* Replace uses of `PyCell_GET` and `PyCell_SET`. These macros are not
safe to use in the free-threaded build. Use `PyCell_GetRef()` and
`PyCell_SetTakeRef()` instead.
* Since `PyCell_GetRef()` returns a strong rather than borrowed ref, some
code restructuring was required, e.g. `frame_get_var()` returns a strong
ref now.
* Add critical sections to `PyCell_GET` and `PyCell_SET`.
* Move critical_section.h earlier in the Python.h file.
* Add `PyCell_GET` to the free-threading howto table of APIs that return
borrowed refs.
* Add additional unit tests for free-threading.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/howto/free-threading-extensions.rst | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Doc/howto/free-threading-extensions.rst b/Doc/howto/free-threading-extensions.rst index 6abe93d..c1ad42e 100644 --- a/Doc/howto/free-threading-extensions.rst +++ b/Doc/howto/free-threading-extensions.rst @@ -167,6 +167,8 @@ that return :term:`strong references <strong reference>`. +-----------------------------------+-----------------------------------+ | :c:func:`PyImport_AddModule` | :c:func:`PyImport_AddModuleRef` | +-----------------------------------+-----------------------------------+ +| :c:func:`PyCell_GET` | :c:func:`PyCell_Get` | ++-----------------------------------+-----------------------------------+ Not all APIs that return borrowed references are problematic. For example, :c:func:`PyTuple_GetItem` is safe because tuples are immutable. |