Skip to content

Commit a19e9a8

Browse files
committed
Exercise critical section generation in testclinic
1 parent 2a7c068 commit a19e9a8

5 files changed

Lines changed: 20 additions & 8 deletions

File tree

Modules/_testclinic.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,11 +2350,14 @@ static PyTypeObject VcNew_Type = {
23502350
};
23512351

23522352

2353-
/* VcInit: __init__ with one required positional-only and one optional keyword arg */
2353+
/* VcInit: __init__ with one required positional-only and one optional keyword
2354+
* arg. Uses @critical_section to exercise the {lock}/impl/{unlock} placement
2355+
* in both the helper body and the vectorcall fast-path inner block. */
23542356

23552357
/*[clinic input]
23562358
class _testclinic.VcInit "PyObject *" "&VcInit_Type"
23572359
@vectorcall
2360+
@critical_section
23582361
_testclinic.VcInit.__init__ as vc_posorkw_init
23592362
a: object
23602363
/
@@ -2363,7 +2366,7 @@ _testclinic.VcInit.__init__ as vc_posorkw_init
23632366

23642367
static int
23652368
vc_posorkw_init_impl(PyObject *self, PyObject *a, PyObject *b)
2366-
/*[clinic end generated code: output=6018424ba9fb0744 input=25e4c2b792040c31]*/
2369+
/*[clinic end generated code: output=6018424ba9fb0744 input=7a4513f78dd42b57]*/
23672370
{
23682371
return 0;
23692372
}

Modules/clinic/_testclinic.c.h

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_testclinic_depr.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_testclinic_kwds.c.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/clinic/libclinic/parse_args.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,14 +1227,15 @@ def _vc_finale(self) -> str:
12271227
if self.func.kind is METHOD_INIT:
12281228
return libclinic.normalize_snippet("""
12291229
{modifications}
1230-
{lock}
12311230
{{
12321231
PyObject *self = _PyType_CAST(type)->tp_alloc(
12331232
_PyType_CAST(type), 0);
12341233
if (self == NULL) {{
12351234
goto exit;
12361235
}}
1237-
int _result = {c_basename}_impl({vc_impl_arguments});
1236+
int _result;
1237+
{lock}
1238+
_result = {c_basename}_impl({vc_impl_arguments});
12381239
{unlock}
12391240
if (_result != 0) {{
12401241
Py_DECREF(self);

0 commit comments

Comments
 (0)