Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Modules/_collectionsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1499,8 +1499,19 @@ deque_remove_impl(dequeobject *deque, PyObject *value)
Py_RETURN_NONE;
}

/*[clinic input]
@critical_section
_collections.deque.__setitem__ as deque_ass_item

deque: dequeobject
i: Py_ssize_t
v: object
/
[clinic start generated code]*/

static int
deque_ass_item_lock_held(dequeobject *deque, Py_ssize_t i, PyObject *v)
deque_ass_item_impl(dequeobject *deque, Py_ssize_t i, PyObject *v)
/*[clinic end generated code: output=28739a830dc69ab1 input=b767e1a4972fa537]*/
{
block *b;
Py_ssize_t n, len=Py_SIZE(deque), halflen=(len+1)>>1, index=i;
Expand Down Expand Up @@ -1531,17 +1542,6 @@ deque_ass_item_lock_held(dequeobject *deque, Py_ssize_t i, PyObject *v)
return 0;
}

static int
deque_ass_item(PyObject *self, Py_ssize_t i, PyObject *v)
{
dequeobject *deque = dequeobject_CAST(self);
int result;
Py_BEGIN_CRITICAL_SECTION(deque);
result = deque_ass_item_lock_held(deque, i, v);
Py_END_CRITICAL_SECTION();
return result;
}

static void
deque_dealloc(PyObject *self)
{
Expand Down
85 changes: 47 additions & 38 deletions Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4983,8 +4983,11 @@ static PyType_Spec pycunion_spec = {
/*
PyCArray_Type
*/
static int Array_ass_item_lock_held(PyObject *, Py_ssize_t, PyObject *);
static int Array_ass_subscript(PyObject *, PyObject *, PyObject *);

/*[clinic input]
class _ctypes.Array "PyObject *" "clinic_state()->PyCArray_Type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b2d780e2e2dc6e8a]*/

static int
Array_init(PyObject *self, PyObject *args, PyObject *kw)
Expand All @@ -5008,7 +5011,7 @@ Array_init(PyObject *self, PyObject *args, PyObject *kw)
for (i = 0; result >= 0 && i < n; ++i) {
PyObject *v = PyTuple_GET_ITEM(args, i);
assert(v != NULL);
result = Array_ass_item_lock_held(self, i, v);
result = Array_ass_item_impl(self, i, v);
}
Py_END_CRITICAL_SECTION();
return result;
Expand Down Expand Up @@ -5192,8 +5195,19 @@ Array_subscript(PyObject *myself, PyObject *item)
return result;
}

/*[clinic input]
@critical_section
_ctypes.Array.__setitem__ as Array_ass_item

myself: self
index: Py_ssize_t
value: object
/
[clinic start generated code]*/

static int
Array_ass_item_lock_held(PyObject *myself, Py_ssize_t index, PyObject *value)
Array_ass_item_impl(PyObject *myself, Py_ssize_t index, PyObject *value)
/*[clinic end generated code: output=8fb1fd51b5b45da8 input=8b6ddb53d6377b96]*/
{
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(myself);

Expand Down Expand Up @@ -5227,19 +5241,19 @@ Array_ass_item_lock_held(PyObject *myself, Py_ssize_t index, PyObject *value)
index, size, ptr);
}

static int
Array_ass_item(PyObject *myself, Py_ssize_t index, PyObject *value)
{
int result;
Py_BEGIN_CRITICAL_SECTION(myself);
result = Array_ass_item_lock_held(myself, index, value);
Py_END_CRITICAL_SECTION();
return result;
}
/*[clinic input]
@critical_section
_ctypes.Array.__setitem__ as Array_ass_subscript

myself: self
item: object
value: object
/
[clinic start generated code]*/

static int
Array_ass_subscript_lock_held(PyObject *myself, PyObject *item, PyObject *value)
Array_ass_subscript_impl(PyObject *myself, PyObject *item, PyObject *value)
/*[clinic end generated code: output=cb9a138e4e40c5ac input=4b7aedebbb357853]*/
{
CDataObject *self = _CDataObject_CAST(myself);

Expand All @@ -5256,7 +5270,7 @@ Array_ass_subscript_lock_held(PyObject *myself, PyObject *item, PyObject *value)
return -1;
if (i < 0)
i += self->b_length;
return Array_ass_item_lock_held(myself, i, value);
return Array_ass_item_impl(myself, i, value);
}
else if (PySlice_Check(item)) {
Py_ssize_t start, stop, step, slicelen, otherlen, i;
Expand All @@ -5281,7 +5295,7 @@ Array_ass_subscript_lock_held(PyObject *myself, PyObject *item, PyObject *value)
int result;
if (item == NULL)
return -1;
result = Array_ass_item_lock_held(myself, cur, item);
result = Array_ass_item_impl(myself, cur, item);
Py_DECREF(item);
if (result == -1)
return -1;
Expand All @@ -5295,17 +5309,6 @@ Array_ass_subscript_lock_held(PyObject *myself, PyObject *item, PyObject *value)
}
}

static int
Array_ass_subscript(PyObject *myself, PyObject *item, PyObject *value)
{
int result;
Py_BEGIN_CRITICAL_SECTION(myself);
result = Array_ass_subscript_lock_held(myself, item, value);
Py_END_CRITICAL_SECTION();
return result;
}


static Py_ssize_t
Array_length(PyObject *myself)
{
Expand Down Expand Up @@ -5624,8 +5627,24 @@ Pointer_item(PyObject *self, Py_ssize_t index)
return res;
}

/*[clinic input]
class _ctypes._Pointer "PyObject *" "clinic_state()->PyCPointer_Type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=452695db70aa7c3e]*/

/*[clinic input]
@critical_section
_ctypes._Pointer.__setitem__ as Pointer_ass_item

myself: self
index: Py_ssize_t
value: object
/
[clinic start generated code]*/

static int
Pointer_ass_item_lock_held(PyObject *myself, Py_ssize_t index, PyObject *value)
Pointer_ass_item_impl(PyObject *myself, Py_ssize_t index, PyObject *value)
/*[clinic end generated code: output=4503430bd55b6c69 input=344ad19b3094558c]*/
{
CDataObject *self = _CDataObject_CAST(myself);
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(self);
Expand Down Expand Up @@ -5670,16 +5689,6 @@ Pointer_ass_item_lock_held(PyObject *myself, Py_ssize_t index, PyObject *value)
index, size, ((char *)deref + offset));
}

static int
Pointer_ass_item(PyObject *self, Py_ssize_t index, PyObject *value)
{
int res;
Py_BEGIN_CRITICAL_SECTION(self);
res = Pointer_ass_item_lock_held(self, index, value);
Py_END_CRITICAL_SECTION();
return res;
}

static PyObject *
Pointer_get_contents_lock_held(PyObject *self, void *closure)
{
Expand Down
47 changes: 46 additions & 1 deletion Modules/_ctypes/clinic/_ctypes.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Modules/_dbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,22 @@ dbm_subscript(PyObject *self, PyObject *key)
return result;
}

/*[clinic input]
@critical_section
_dbm.dbm.__setitem__ as dbm_ass_sub

v: object
w: object
/
[clinic start generated code]*/

static int
dbm_ass_sub_lock_held(PyObject *self, PyObject *v, PyObject *w)
dbm_ass_sub_impl(dbmobject *self, PyObject *v, PyObject *w)
/*[clinic end generated code: output=33e861810d1fd44a input=4f10cc93a02142ee]*/
{
datum krec, drec;
Py_ssize_t tmp_size;
dbmobject *dp = dbmobject_CAST(self);
dbmobject *dp = self;

if ( !PyArg_Parse(v, "s#", &krec.dptr, &tmp_size) ) {
PyErr_SetString(PyExc_TypeError,
Expand Down Expand Up @@ -279,16 +289,6 @@ dbm_ass_sub_lock_held(PyObject *self, PyObject *v, PyObject *w)
return 0;
}

static int
dbm_ass_sub(PyObject *self, PyObject *v, PyObject *w)
{
int result;
Py_BEGIN_CRITICAL_SECTION(self);
result = dbm_ass_sub_lock_held(self, v, w);
Py_END_CRITICAL_SECTION();
return result;
}

/*[clinic input]
@critical_section
_dbm.dbm.close
Expand Down
24 changes: 12 additions & 12 deletions Modules/_gdbmmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,22 @@ _gdbm_gdbm_get_impl(gdbmobject *self, PyObject *key, PyObject *default_value)
return res;
}

/*[clinic input]
@critical_section
_gdbm.gdbm.__setitem__ as gdbm_ass_sub

v: object
w: object
/
[clinic start generated code]*/

static int
gdbm_ass_sub_lock_held(PyObject *op, PyObject *v, PyObject *w)
gdbm_ass_sub_impl(gdbmobject *self, PyObject *v, PyObject *w)
/*[clinic end generated code: output=b46cce6ffa309dab input=fbd980f3b49e2f91]*/
{
datum krec, drec;
const char *failmsg = "gdbm mappings have bytes or string indices only";
gdbmobject *dp = _gdbmobject_CAST(op);
gdbmobject *dp = self;
_gdbm_state *state = PyType_GetModuleState(Py_TYPE(dp));

if (!parse_datum(v, &krec, failmsg)) {
Expand Down Expand Up @@ -356,16 +366,6 @@ gdbm_ass_sub_lock_held(PyObject *op, PyObject *v, PyObject *w)
return 0;
}

static int
gdbm_ass_sub(PyObject *op, PyObject *v, PyObject *w)
{
int result;
Py_BEGIN_CRITICAL_SECTION(op);
result = gdbm_ass_sub_lock_held(op, v, w);
Py_END_CRITICAL_SECTION();
return result;
}

/*[clinic input]
@permit_long_summary
@critical_section
Expand Down
17 changes: 16 additions & 1 deletion Modules/clinic/_collectionsmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion Modules/clinic/_dbmmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading