]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-127271: Replace use of PyCell_GET/SET (gh-127272)
authorNeil Schemenauer <nas-github@arctrix.com>
Tue, 3 Dec 2024 18:33:06 +0000 (10:33 -0800)
committerGitHub <noreply@github.com>
Tue, 3 Dec 2024 18:33:06 +0000 (10:33 -0800)
commitfc5a0dc22483a35068888e828c65796d7a792c14
treef3c92006e7f12df9515e20346d31abe01c21c800
parent276cd66ccbbf85996a57bd1db3dd29b93a6eab64
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.
Doc/howto/free-threading-extensions.rst
Include/Python.h
Include/cpython/cellobject.h
Lib/test/test_free_threading/test_races.py [new file with mode: 0644]
Objects/cellobject.c
Objects/frameobject.c
Objects/typeobject.c
Python/bltinmodule.c