Skip to content

Support specifying object to lock in Argument Clinic's @critical_section directive#112213

@colesbury

Description

@colesbury

Feature or enhancement

#111903 added support for the @critical_section directive to Argument Clinic. It currently assumes that the first argument is the one that should be locked. This is a good default, but there are at least a few cases where we want to lock a different argument.

For example, in the _weakref module, we generally want to lock the object argument, not the _weakref module itself.

Let's add support for specifying the argument to lock. For example,

/*[clinic input]@critical_section object_weakref.getweakrefs object: object /Return a list of all weak reference objects pointing to 'object'.[clinic start generated code]*/staticPyObject*_weakref_getweakrefs(PyObject*module, PyObject*object) /*[clinic end generated code: output=25c7731d8e011824 input=00c6d0e5d3206693]*/

Linked PRs

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions