summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Modules/_operator.c
diff options
context:
space:
mode:
authorshadchin <[email protected]>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Modules/_operator.c
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Modules/_operator.c')
-rw-r--r--contrib/tools/python3/src/Modules/_operator.c154
1 files changed, 77 insertions, 77 deletions
diff --git a/contrib/tools/python3/src/Modules/_operator.c b/contrib/tools/python3/src/Modules/_operator.c
index 72bd4bdd5d4..0136e380d2a 100644
--- a/contrib/tools/python3/src/Modules/_operator.c
+++ b/contrib/tools/python3/src/Modules/_operator.c
@@ -494,12 +494,12 @@ _operator_indexOf_impl(PyObject *module, PyObject *a, PyObject *b)
/*[clinic input]
_operator.countOf = _operator.indexOf
-Return the number of items in a which are, or which equal, b.
+Return the number of items in a which are, or which equal, b.
[clinic start generated code]*/
static Py_ssize_t
_operator_countOf_impl(PyObject *module, PyObject *a, PyObject *b)
-/*[clinic end generated code: output=9e1623197daf3382 input=93ea57f170f3f0bb]*/
+/*[clinic end generated code: output=9e1623197daf3382 input=93ea57f170f3f0bb]*/
{
return PySequence_Count(a, b);
}
@@ -735,7 +735,7 @@ _tscmp(const unsigned char *a, const unsigned char *b,
volatile const unsigned char *left;
volatile const unsigned char *right;
Py_ssize_t i;
- volatile unsigned char result;
+ volatile unsigned char result;
/* loop count depends on length of b */
length = len_b;
@@ -785,8 +785,8 @@ _operator_length_hint_impl(PyObject *module, PyObject *obj,
return PyObject_LengthHint(obj, default_value);
}
-/* NOTE: Keep in sync with _hashopenssl.c implementation. */
-
+/* NOTE: Keep in sync with _hashopenssl.c implementation. */
+
/*[clinic input]
_operator._compare_digest = _operator.eq
@@ -939,7 +939,7 @@ typedef struct {
PyObject_HEAD
Py_ssize_t nitems;
PyObject *item;
- Py_ssize_t index; // -1 unless *item* is a single non-negative integer index
+ Py_ssize_t index; // -1 unless *item* is a single non-negative integer index
} itemgetterobject;
static PyTypeObject itemgetter_type;
@@ -951,7 +951,7 @@ itemgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
itemgetterobject *ig;
PyObject *item;
Py_ssize_t nitems;
- Py_ssize_t index;
+ Py_ssize_t index;
if (!_PyArg_NoKeywords("itemgetter", kwds))
return NULL;
@@ -971,21 +971,21 @@ itemgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_INCREF(item);
ig->item = item;
ig->nitems = nitems;
- ig->index = -1;
- if (PyLong_CheckExact(item)) {
- index = PyLong_AsSsize_t(item);
- if (index < 0) {
- /* If we get here, then either the index conversion failed
- * due to being out of range, or the index was a negative
- * integer. Either way, we clear any possible exception
- * and fall back to the slow path, where ig->index is -1.
- */
- PyErr_Clear();
- }
- else {
- ig->index = index;
- }
- }
+ ig->index = -1;
+ if (PyLong_CheckExact(item)) {
+ index = PyLong_AsSsize_t(item);
+ if (index < 0) {
+ /* If we get here, then either the index conversion failed
+ * due to being out of range, or the index was a negative
+ * integer. Either way, we clear any possible exception
+ * and fall back to the slow path, where ig->index is -1.
+ */
+ PyErr_Clear();
+ }
+ else {
+ ig->index = index;
+ }
+ }
PyObject_GC_Track(ig);
return (PyObject *)ig;
@@ -1012,24 +1012,24 @@ itemgetter_call(itemgetterobject *ig, PyObject *args, PyObject *kw)
PyObject *obj, *result;
Py_ssize_t i, nitems=ig->nitems;
- assert(PyTuple_CheckExact(args));
+ assert(PyTuple_CheckExact(args));
if (!_PyArg_NoKeywords("itemgetter", kw))
return NULL;
- if (!_PyArg_CheckPositional("itemgetter", PyTuple_GET_SIZE(args), 1, 1))
+ if (!_PyArg_CheckPositional("itemgetter", PyTuple_GET_SIZE(args), 1, 1))
return NULL;
-
- obj = PyTuple_GET_ITEM(args, 0);
- if (nitems == 1) {
- if (ig->index >= 0
- && PyTuple_CheckExact(obj)
- && ig->index < PyTuple_GET_SIZE(obj))
- {
- result = PyTuple_GET_ITEM(obj, ig->index);
- Py_INCREF(result);
- return result;
- }
+
+ obj = PyTuple_GET_ITEM(args, 0);
+ if (nitems == 1) {
+ if (ig->index >= 0
+ && PyTuple_CheckExact(obj)
+ && ig->index < PyTuple_GET_SIZE(obj))
+ {
+ result = PyTuple_GET_ITEM(obj, ig->index);
+ Py_INCREF(result);
+ return result;
+ }
return PyObject_GetItem(obj, ig->item);
- }
+ }
assert(PyTuple_Check(ig->item));
assert(PyTuple_GET_SIZE(ig->item) == nitems);
@@ -1071,7 +1071,7 @@ itemgetter_repr(itemgetterobject *ig)
}
static PyObject *
-itemgetter_reduce(itemgetterobject *ig, PyObject *Py_UNUSED(ignored))
+itemgetter_reduce(itemgetterobject *ig, PyObject *Py_UNUSED(ignored))
{
if (ig->nitems == 1)
return Py_BuildValue("O(O)", Py_TYPE(ig), ig->item);
@@ -1100,10 +1100,10 @@ static PyTypeObject itemgetter_type = {
0, /* tp_itemsize */
/* methods */
(destructor)itemgetter_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
(reprfunc)itemgetter_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -1172,7 +1172,7 @@ attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
for (idx = 0; idx < nattrs; ++idx) {
PyObject *item = PyTuple_GET_ITEM(args, idx);
Py_ssize_t item_len;
- const void *data;
+ const void *data;
unsigned int kind;
int dot_count;
@@ -1316,9 +1316,9 @@ attrgetter_call(attrgetterobject *ag, PyObject *args, PyObject *kw)
if (!_PyArg_NoKeywords("attrgetter", kw))
return NULL;
- if (!_PyArg_CheckPositional("attrgetter", PyTuple_GET_SIZE(args), 1, 1))
+ if (!_PyArg_CheckPositional("attrgetter", PyTuple_GET_SIZE(args), 1, 1))
return NULL;
- obj = PyTuple_GET_ITEM(args, 0);
+ obj = PyTuple_GET_ITEM(args, 0);
if (ag->nattrs == 1) /* ag->attr is always a tuple */
return dotted_getattr(obj, PyTuple_GET_ITEM(ag->attr, 0));
@@ -1414,7 +1414,7 @@ attrgetter_repr(attrgetterobject *ag)
}
static PyObject *
-attrgetter_reduce(attrgetterobject *ag, PyObject *Py_UNUSED(ignored))
+attrgetter_reduce(attrgetterobject *ag, PyObject *Py_UNUSED(ignored))
{
PyObject *attrstrings = attrgetter_args(ag);
if (attrstrings == NULL)
@@ -1445,10 +1445,10 @@ static PyTypeObject attrgetter_type = {
0, /* tp_itemsize */
/* methods */
(destructor)attrgetter_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
(reprfunc)attrgetter_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -1561,9 +1561,9 @@ methodcaller_call(methodcallerobject *mc, PyObject *args, PyObject *kw)
if (!_PyArg_NoKeywords("methodcaller", kw))
return NULL;
- if (!_PyArg_CheckPositional("methodcaller", PyTuple_GET_SIZE(args), 1, 1))
+ if (!_PyArg_CheckPositional("methodcaller", PyTuple_GET_SIZE(args), 1, 1))
return NULL;
- obj = PyTuple_GET_ITEM(args, 0);
+ obj = PyTuple_GET_ITEM(args, 0);
method = PyObject_GetAttr(obj, mc->name);
if (method == NULL)
return NULL;
@@ -1649,7 +1649,7 @@ done:
}
static PyObject *
-methodcaller_reduce(methodcallerobject *mc, PyObject *Py_UNUSED(ignored))
+methodcaller_reduce(methodcallerobject *mc, PyObject *Py_UNUSED(ignored))
{
PyObject *newargs;
if (!mc->kwds || PyDict_GET_SIZE(mc->kwds) == 0) {
@@ -1684,7 +1684,7 @@ methodcaller_reduce(methodcallerobject *mc, PyObject *Py_UNUSED(ignored))
newargs[0] = (PyObject *)Py_TYPE(mc);
newargs[1] = mc->name;
- constructor = PyObject_VectorcallDict(partial, newargs, 2, mc->kwds);
+ constructor = PyObject_VectorcallDict(partial, newargs, 2, mc->kwds);
Py_DECREF(partial);
return Py_BuildValue("NO", constructor, mc->args);
@@ -1711,10 +1711,10 @@ static PyTypeObject methodcaller_type = {
0, /* tp_itemsize */
/* methods */
(destructor)methodcaller_dealloc, /* tp_dealloc */
- 0, /* tp_vectorcall_offset */
+ 0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
- 0, /* tp_as_async */
+ 0, /* tp_as_async */
(reprfunc)methodcaller_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
@@ -1748,38 +1748,38 @@ static PyTypeObject methodcaller_type = {
};
-static int
-operator_exec(PyObject *module)
-{
- PyTypeObject *types[] = {
- &itemgetter_type,
- &attrgetter_type,
- &methodcaller_type
- };
+static int
+operator_exec(PyObject *module)
+{
+ PyTypeObject *types[] = {
+ &itemgetter_type,
+ &attrgetter_type,
+ &methodcaller_type
+ };
+
+ for (size_t i = 0; i < Py_ARRAY_LENGTH(types); i++) {
+ if (PyModule_AddType(module, types[i]) < 0) {
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
+static struct PyModuleDef_Slot operator_slots[] = {
+ {Py_mod_exec, operator_exec},
+ {0, NULL}
+};
- for (size_t i = 0; i < Py_ARRAY_LENGTH(types); i++) {
- if (PyModule_AddType(module, types[i]) < 0) {
- return -1;
- }
- }
- return 0;
-}
-
-
-static struct PyModuleDef_Slot operator_slots[] = {
- {Py_mod_exec, operator_exec},
- {0, NULL}
-};
-
-
static struct PyModuleDef operatormodule = {
PyModuleDef_HEAD_INIT,
"_operator",
operator_doc,
- 0,
+ 0,
operator_methods,
- operator_slots,
+ operator_slots,
NULL,
NULL,
NULL
@@ -1788,5 +1788,5 @@ static struct PyModuleDef operatormodule = {
PyMODINIT_FUNC
PyInit__operator(void)
{
- return PyModuleDef_Init(&operatormodule);
+ return PyModuleDef_Init(&operatormodule);
}