]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-111903: Add `@critical_section` directive to Argument Clinic. (#111904)
authorSam Gross <colesbury@gmail.com>
Tue, 14 Nov 2023 10:47:46 +0000 (05:47 -0500)
committerGitHub <noreply@github.com>
Tue, 14 Nov 2023 10:47:46 +0000 (10:47 +0000)
commit324531df909721978446d504186738a33ab03fd5
treefb3959265c6530ad8049e7511b428334c1657ac5
parent16055c160412544e2a49794aaf3aa70c584f843a
gh-111903: Add `@critical_section` directive to Argument Clinic. (#111904)

The `@critical_section` directive instructs Argument Clinic to generate calls
to `Py_BEGIN_CRITICAL_SECTION()` and `Py_END_CRITICAL_SECTION()` around the
bound function. In `--disable-gil` builds, these calls will lock and unlock
the `self` object. They are no-ops in the default build.

This is used in one place (`_io._Buffered.close`) as a demonstration.
Subsequent PRs will use it more widely in the `_io.Buffered` bindings.
Lib/test/clinic.test.c
Misc/NEWS.d/next/Tools-Demos/2023-11-09-13-04-29.gh-issue-111903.7Prryr.rst [new file with mode: 0644]
Modules/_io/bufferedio.c
Modules/_io/clinic/bufferedio.c.h
Tools/clinic/clinic.py