aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Python/context.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/tools/python3/src/Python/context.c
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/tools/python3/src/Python/context.c')
-rw-r--r--contrib/tools/python3/src/Python/context.c194
1 files changed, 97 insertions, 97 deletions
diff --git a/contrib/tools/python3/src/Python/context.c b/contrib/tools/python3/src/Python/context.c
index a3bfd99e5f..bacc7010c4 100644
--- a/contrib/tools/python3/src/Python/context.c
+++ b/contrib/tools/python3/src/Python/context.c
@@ -1,12 +1,12 @@
#include "Python.h"
-#include "pycore_context.h"
-#include "pycore_gc.h" // _PyObject_GC_MAY_BE_TRACKED()
-#include "pycore_hamt.h"
-#include "pycore_object.h"
-#include "pycore_pyerrors.h"
-#include "pycore_pystate.h" // _PyThreadState_GET()
-#include "structmember.h" // PyMemberDef
+#include "pycore_context.h"
+#include "pycore_gc.h" // _PyObject_GC_MAY_BE_TRACKED()
+#include "pycore_hamt.h"
+#include "pycore_object.h"
+#include "pycore_pyerrors.h"
+#include "pycore_pystate.h" // _PyThreadState_GET()
+#include "structmember.h" // PyMemberDef
#define CONTEXT_FREELIST_MAXLEN 255
@@ -103,15 +103,15 @@ PyContext_CopyCurrent(void)
}
-static int
-_PyContext_Enter(PyThreadState *ts, PyObject *octx)
+static int
+_PyContext_Enter(PyThreadState *ts, PyObject *octx)
{
ENSURE_Context(octx, -1)
PyContext *ctx = (PyContext *)octx;
if (ctx->ctx_entered) {
- _PyErr_Format(ts, PyExc_RuntimeError,
- "cannot enter context: %R is already entered", ctx);
+ _PyErr_Format(ts, PyExc_RuntimeError,
+ "cannot enter context: %R is already entered", ctx);
return -1;
}
@@ -127,17 +127,17 @@ _PyContext_Enter(PyThreadState *ts, PyObject *octx)
int
-PyContext_Enter(PyObject *octx)
+PyContext_Enter(PyObject *octx)
+{
+ PyThreadState *ts = _PyThreadState_GET();
+ assert(ts != NULL);
+ return _PyContext_Enter(ts, octx);
+}
+
+
+static int
+_PyContext_Exit(PyThreadState *ts, PyObject *octx)
{
- PyThreadState *ts = _PyThreadState_GET();
- assert(ts != NULL);
- return _PyContext_Enter(ts, octx);
-}
-
-
-static int
-_PyContext_Exit(PyThreadState *ts, PyObject *octx)
-{
ENSURE_Context(octx, -1)
PyContext *ctx = (PyContext *)octx;
@@ -164,15 +164,15 @@ _PyContext_Exit(PyThreadState *ts, PyObject *octx)
return 0;
}
-int
-PyContext_Exit(PyObject *octx)
-{
- PyThreadState *ts = _PyThreadState_GET();
- assert(ts != NULL);
- return _PyContext_Exit(ts, octx);
-}
+int
+PyContext_Exit(PyObject *octx)
+{
+ PyThreadState *ts = _PyThreadState_GET();
+ assert(ts != NULL);
+ return _PyContext_Exit(ts, octx);
+}
+
-
PyObject *
PyContextVar_New(const char *name, PyObject *def)
{
@@ -192,7 +192,7 @@ PyContextVar_Get(PyObject *ovar, PyObject *def, PyObject **val)
ENSURE_ContextVar(ovar, -1)
PyContextVar *var = (PyContextVar *)ovar;
- PyThreadState *ts = _PyThreadState_GET();
+ PyThreadState *ts = _PyThreadState_GET();
assert(ts != NULL);
if (ts->context == NULL) {
goto not_found;
@@ -396,7 +396,7 @@ context_new_from_vars(PyHamtObject *vars)
static inline PyContext *
context_get(void)
{
- PyThreadState *ts = _PyThreadState_GET();
+ PyThreadState *ts = _PyThreadState_GET();
assert(ts != NULL);
PyContext *current_ctx = (PyContext *)ts->context;
if (current_ctx == NULL) {
@@ -542,17 +542,17 @@ _contextvars.Context.get
key: object
default: object = None
/
-
-Return the value for `key` if `key` has the value in the context object.
-
-If `key` does not exist, return `default`. If `default` is not given,
-return None.
+
+Return the value for `key` if `key` has the value in the context object.
+
+If `key` does not exist, return `default`. If `default` is not given,
+return None.
[clinic start generated code]*/
static PyObject *
_contextvars_Context_get_impl(PyContext *self, PyObject *key,
PyObject *default_value)
-/*[clinic end generated code: output=0c54aa7664268189 input=c8eeb81505023995]*/
+/*[clinic end generated code: output=0c54aa7664268189 input=c8eeb81505023995]*/
{
if (context_check_key_type(key)) {
return NULL;
@@ -574,15 +574,15 @@ _contextvars_Context_get_impl(PyContext *self, PyObject *key,
/*[clinic input]
_contextvars.Context.items
-
-Return all variables and their values in the context object.
-
-The result is returned as a list of 2-tuples (variable, value).
+
+Return all variables and their values in the context object.
+
+The result is returned as a list of 2-tuples (variable, value).
[clinic start generated code]*/
static PyObject *
_contextvars_Context_items_impl(PyContext *self)
-/*[clinic end generated code: output=fa1655c8a08502af input=00db64ae379f9f42]*/
+/*[clinic end generated code: output=fa1655c8a08502af input=00db64ae379f9f42]*/
{
return _PyHamt_NewIterItems(self->ctx_vars);
}
@@ -590,13 +590,13 @@ _contextvars_Context_items_impl(PyContext *self)
/*[clinic input]
_contextvars.Context.keys
-
-Return a list of all variables in the context object.
+
+Return a list of all variables in the context object.
[clinic start generated code]*/
static PyObject *
_contextvars_Context_keys_impl(PyContext *self)
-/*[clinic end generated code: output=177227c6b63ec0e2 input=114b53aebca3449c]*/
+/*[clinic end generated code: output=177227c6b63ec0e2 input=114b53aebca3449c]*/
{
return _PyHamt_NewIterKeys(self->ctx_vars);
}
@@ -604,13 +604,13 @@ _contextvars_Context_keys_impl(PyContext *self)
/*[clinic input]
_contextvars.Context.values
-
-Return a list of all variables' values in the context object.
+
+Return a list of all variables' values in the context object.
[clinic start generated code]*/
static PyObject *
_contextvars_Context_values_impl(PyContext *self)
-/*[clinic end generated code: output=d286dabfc8db6dde input=ce8075d04a6ea526]*/
+/*[clinic end generated code: output=d286dabfc8db6dde input=ce8075d04a6ea526]*/
{
return _PyHamt_NewIterValues(self->ctx_vars);
}
@@ -618,13 +618,13 @@ _contextvars_Context_values_impl(PyContext *self)
/*[clinic input]
_contextvars.Context.copy
-
-Return a shallow copy of the context object.
+
+Return a shallow copy of the context object.
[clinic start generated code]*/
static PyObject *
_contextvars_Context_copy_impl(PyContext *self)
-/*[clinic end generated code: output=30ba8896c4707a15 input=ebafdbdd9c72d592]*/
+/*[clinic end generated code: output=30ba8896c4707a15 input=ebafdbdd9c72d592]*/
{
return (PyObject *)context_new_from_vars(self->ctx_vars);
}
@@ -634,22 +634,22 @@ static PyObject *
context_run(PyContext *self, PyObject *const *args,
Py_ssize_t nargs, PyObject *kwnames)
{
- PyThreadState *ts = _PyThreadState_GET();
-
+ PyThreadState *ts = _PyThreadState_GET();
+
if (nargs < 1) {
- _PyErr_SetString(ts, PyExc_TypeError,
- "run() missing 1 required positional argument");
+ _PyErr_SetString(ts, PyExc_TypeError,
+ "run() missing 1 required positional argument");
return NULL;
}
- if (_PyContext_Enter(ts, (PyObject *)self)) {
+ if (_PyContext_Enter(ts, (PyObject *)self)) {
return NULL;
}
- PyObject *call_result = _PyObject_VectorcallTstate(
- ts, args[0], args + 1, nargs - 1, kwnames);
+ PyObject *call_result = _PyObject_VectorcallTstate(
+ ts, args[0], args + 1, nargs - 1, kwnames);
- if (_PyContext_Exit(ts, (PyObject *)self)) {
+ if (_PyContext_Exit(ts, (PyObject *)self)) {
return NULL;
}
@@ -663,7 +663,7 @@ static PyMethodDef PyContext_methods[] = {
_CONTEXTVARS_CONTEXT_KEYS_METHODDEF
_CONTEXTVARS_CONTEXT_VALUES_METHODDEF
_CONTEXTVARS_CONTEXT_COPY_METHODDEF
- {"run", (PyCFunction)(void(*)(void))context_run, METH_FASTCALL | METH_KEYWORDS, NULL},
+ {"run", (PyCFunction)(void(*)(void))context_run, METH_FASTCALL | METH_KEYWORDS, NULL},
{NULL, NULL}
};
@@ -942,19 +942,19 @@ error:
_contextvars.ContextVar.get
default: object = NULL
/
-
-Return a value for the context variable for the current context.
-
-If there is no value for the variable in the current context, the method will:
- * return the value of the default argument of the method, if provided; or
- * return the default value for the context variable, if it was created
- with one; or
- * raise a LookupError.
+
+Return a value for the context variable for the current context.
+
+If there is no value for the variable in the current context, the method will:
+ * return the value of the default argument of the method, if provided; or
+ * return the default value for the context variable, if it was created
+ with one; or
+ * raise a LookupError.
[clinic start generated code]*/
static PyObject *
_contextvars_ContextVar_get_impl(PyContextVar *self, PyObject *default_value)
-/*[clinic end generated code: output=0746bd0aa2ced7bf input=30aa2ab9e433e401]*/
+/*[clinic end generated code: output=0746bd0aa2ced7bf input=30aa2ab9e433e401]*/
{
if (!PyContextVar_CheckExact(self)) {
PyErr_SetString(
@@ -979,18 +979,18 @@ _contextvars_ContextVar_get_impl(PyContextVar *self, PyObject *default_value)
_contextvars.ContextVar.set
value: object
/
-
-Call to set a new value for the context variable in the current context.
-
-The required value argument is the new value for the context variable.
-
-Returns a Token object that can be used to restore the variable to its previous
-value via the `ContextVar.reset()` method.
+
+Call to set a new value for the context variable in the current context.
+
+The required value argument is the new value for the context variable.
+
+Returns a Token object that can be used to restore the variable to its previous
+value via the `ContextVar.reset()` method.
[clinic start generated code]*/
static PyObject *
_contextvars_ContextVar_set(PyContextVar *self, PyObject *value)
-/*[clinic end generated code: output=446ed5e820d6d60b input=c0a6887154227453]*/
+/*[clinic end generated code: output=446ed5e820d6d60b input=c0a6887154227453]*/
{
return PyContextVar_Set((PyObject *)self, value);
}
@@ -999,16 +999,16 @@ _contextvars_ContextVar_set(PyContextVar *self, PyObject *value)
_contextvars.ContextVar.reset
token: object
/
-
-Reset the context variable.
-
-The variable is reset to the value it had before the `ContextVar.set()` that
-created the token was used.
+
+Reset the context variable.
+
+The variable is reset to the value it had before the `ContextVar.set()` that
+created the token was used.
[clinic start generated code]*/
static PyObject *
_contextvars_ContextVar_reset(PyContextVar *self, PyObject *token)
-/*[clinic end generated code: output=d4ee34d0742d62ee input=ebe2881e5af4ffda]*/
+/*[clinic end generated code: output=d4ee34d0742d62ee input=ebe2881e5af4ffda]*/
{
if (!PyContextToken_CheckExact(token)) {
PyErr_Format(PyExc_TypeError,
@@ -1033,8 +1033,8 @@ static PyMethodDef PyContextVar_methods[] = {
_CONTEXTVARS_CONTEXTVAR_GET_METHODDEF
_CONTEXTVARS_CONTEXTVAR_SET_METHODDEF
_CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF
- {"__class_getitem__", (PyCFunction)Py_GenericAlias,
- METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
+ {"__class_getitem__", (PyCFunction)Py_GenericAlias,
+ METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
{NULL, NULL}
};
@@ -1173,17 +1173,17 @@ static PyGetSetDef PyContextTokenType_getsetlist[] = {
{NULL}
};
-static PyMethodDef PyContextTokenType_methods[] = {
- {"__class_getitem__", (PyCFunction)Py_GenericAlias,
- METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
- {NULL}
-};
-
+static PyMethodDef PyContextTokenType_methods[] = {
+ {"__class_getitem__", (PyCFunction)Py_GenericAlias,
+ METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
+ {NULL}
+};
+
PyTypeObject PyContextToken_Type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"Token",
sizeof(PyContextToken),
- .tp_methods = PyContextTokenType_methods,
+ .tp_methods = PyContextTokenType_methods,
.tp_getset = PyContextTokenType_getsetlist,
.tp_dealloc = (destructor)token_tp_dealloc,
.tp_getattro = PyObject_GenericGetAttr,
@@ -1270,10 +1270,10 @@ get_token_missing(void)
///////////////////////////
-void
-_PyContext_ClearFreeList(void)
+void
+_PyContext_ClearFreeList(void)
{
- for (; ctx_freelist_len; ctx_freelist_len--) {
+ for (; ctx_freelist_len; ctx_freelist_len--) {
PyContext *ctx = ctx_freelist;
ctx_freelist = (PyContext *)ctx->ctx_weakreflist;
ctx->ctx_weakreflist = NULL;
@@ -1286,8 +1286,8 @@ void
_PyContext_Fini(void)
{
Py_CLEAR(_token_missing);
- _PyContext_ClearFreeList();
- _PyHamt_Fini();
+ _PyContext_ClearFreeList();
+ _PyHamt_Fini();
}