Skip to content

PyDict_Next documentation should mention strong references when using a critical section in the free-threading build #138098

@eendebakpt

Description

@eendebakpt

Documentation

In the documentation for PyDict_Next it is mentioned that the method is not safe in the free-threaded build and it is suggested to use a critical section. With the critical section the usage of PyDict_Next itself is safe. But the references set to key and value are borrowed references, which are not safe to use when the critical section lock is suspended inside the while loop.

(noted in #119438 (comment))

The documentation should mention the usage of strong references.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions