You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PyCell_GET and PyCell_SET macros are not safe for free-threading builds. First, they don't the correct locking. Second, PyCell_GET returns a borrowed reference.
For CPython internals, the usages of these macros can be replaced (either with PyCell_GetRef(), PyCell_SetTakeRef(), or similar). For external API users, these macros will need to be marked as deprecated, at least for free-threaded builds.
These macros are not safe to use in the free-threaded build. Use
`PyCell_GetRef()` and `PyCell_SetTakeRef()` instead. Add `PyCell_GET` to
the free-threading howto table of APIs that return borrowed refs. Add
critical sections to `PyCell_GET` and `PyCell_SET`.
* 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.
Bug report
Bug description:
The
PyCell_GET
andPyCell_SET
macros are not safe for free-threading builds. First, they don't the correct locking. Second,PyCell_GET
returns a borrowed reference.For CPython internals, the usages of these macros can be replaced (either with
PyCell_GetRef()
,PyCell_SetTakeRef()
, or similar). For external API users, these macros will need to be marked as deprecated, at least for free-threaded builds.CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: