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
29 changes: 16 additions & 13 deletions Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -5513,15 +5513,16 @@ static PyMethodDef Simple_methods[] = {
{ NULL, NULL },
};

/*[clinic input]
@critical_section
_ctypes.Simple.__bool__ as Simple_bool
[clinic start generated code]*/

static int
Simple_bool(PyObject *op)
Simple_bool_impl(CDataObject *self)
/*[clinic end generated code: output=c4466ece6a99fe8b input=326a1c8b24d8918e]*/
{
int cmp;
CDataObject *self = _CDataObject_CAST(op);
Py_BEGIN_CRITICAL_SECTION(self);
cmp = memcmp(self->b_ptr, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", self->b_size);
Py_END_CRITICAL_SECTION();
return cmp;
return memcmp(self->b_ptr, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", self->b_size);
}

/* "%s(%s)" % (self.__class__.__name__, self.value) */
Expand Down Expand Up @@ -5988,14 +5989,16 @@ Pointer_subscript(PyObject *myself, PyObject *item)
}
}

/*[clinic input]
@critical_section
_ctypes._Pointer.__bool__ as Pointer_bool
[clinic start generated code]*/

static int
Pointer_bool(PyObject *self)
Pointer_bool_impl(PyObject *self)
/*[clinic end generated code: output=0139acaf4d395a69 input=672b8d35e7e0752d]*/
{
int res;
Py_BEGIN_CRITICAL_SECTION(self);
res = *(void **)_CDataObject_CAST(self)->b_ptr != NULL;
Py_END_CRITICAL_SECTION();
return res;
return *(void **)_CDataObject_CAST(self)->b_ptr != NULL;
}

static PyType_Slot pycpointer_slots[] = {
Expand Down
32 changes: 31 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.

20 changes: 11 additions & 9 deletions Python/Python-tokenize.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ get_tokenize_state(PyObject *module) {
get_tokenize_state(PyType_GetModuleByDef(type, &_tokenizemodule))

#include "pycore_runtime.h"
#include "clinic/Python-tokenize.c.h"

/*[clinic input]
module _tokenizer
Expand All @@ -39,6 +38,8 @@ typedef struct
Py_ssize_t byte_col_offset_diff;
} tokenizeriterobject;

#include "clinic/Python-tokenize.c.h"

/*[clinic input]
@classmethod
_tokenizer.tokenizeriter.__new__ as tokenizeriter_new
Expand Down Expand Up @@ -228,17 +229,21 @@ _get_col_offsets(tokenizeriterobject *it, const struct token *token,
return 0;
}

/*[clinic input]
@critical_section
_tokenizer.tokenizeriter.__next__ as tokenizeriter_next
[clinic start generated code]*/

static PyObject *
tokenizeriter_next(PyObject *op)
tokenizeriter_next_impl(tokenizeriterobject *self)
/*[clinic end generated code: output=745c9c646781ff45 input=66f70c965ba8ccfe]*/
{
tokenizeriterobject *it = (tokenizeriterobject*)op;
tokenizeriterobject *it = self;
PyObject* result = NULL;

Py_BEGIN_CRITICAL_SECTION(it);

if (it->done) {
PyErr_SetString(PyExc_StopIteration, "EOF");
goto unlock;
return NULL;
}

struct token token;
Expand Down Expand Up @@ -324,9 +329,6 @@ tokenizeriter_next(PyObject *op)
if (type == ENDMARKER) {
it->done = 1;
}

unlock:;
Py_END_CRITICAL_SECTION();
return result;
}

Expand Down
18 changes: 17 additions & 1 deletion Python/clinic/Python-tokenize.c.h

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

Loading