Skip to content

PyCell_GET/SET are not thread-safe in free-threaded builds #127271

Closed
@nascheme

Description

@nascheme

Bug report

Bug description:

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.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions