LCOV - code coverage report
Current view: top level - Python/clinic - context.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 33 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 6 0.0 %
Branches: 0 16 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*[clinic input]
       2                 :            : preserve
       3                 :            : [clinic start generated code]*/
       4                 :            : 
       5                 :            : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
       6                 :            : #  include "pycore_gc.h"            // PyGC_Head
       7                 :            : #  include "pycore_runtime.h"       // _Py_ID()
       8                 :            : #endif
       9                 :            : 
      10                 :            : 
      11                 :            : PyDoc_STRVAR(_contextvars_Context_get__doc__,
      12                 :            : "get($self, key, default=None, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Return the value for `key` if `key` has the value in the context object.\n"
      16                 :            : "\n"
      17                 :            : "If `key` does not exist, return `default`. If `default` is not given,\n"
      18                 :            : "return None.");
      19                 :            : 
      20                 :            : #define _CONTEXTVARS_CONTEXT_GET_METHODDEF    \
      21                 :            :     {"get", _PyCFunction_CAST(_contextvars_Context_get), METH_FASTCALL, _contextvars_Context_get__doc__},
      22                 :            : 
      23                 :            : static PyObject *
      24                 :            : _contextvars_Context_get_impl(PyContext *self, PyObject *key,
      25                 :            :                               PyObject *default_value);
      26                 :            : 
      27                 :            : static PyObject *
      28                 :          0 : _contextvars_Context_get(PyContext *self, PyObject *const *args, Py_ssize_t nargs)
      29                 :            : {
      30                 :          0 :     PyObject *return_value = NULL;
      31                 :            :     PyObject *key;
      32                 :          0 :     PyObject *default_value = Py_None;
      33                 :            : 
      34   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("get", nargs, 1, 2)) {
                   #  # ]
      35                 :          0 :         goto exit;
      36                 :            :     }
      37                 :          0 :     key = args[0];
      38         [ #  # ]:          0 :     if (nargs < 2) {
      39                 :          0 :         goto skip_optional;
      40                 :            :     }
      41                 :          0 :     default_value = args[1];
      42                 :          0 : skip_optional:
      43                 :          0 :     return_value = _contextvars_Context_get_impl(self, key, default_value);
      44                 :            : 
      45                 :          0 : exit:
      46                 :          0 :     return return_value;
      47                 :            : }
      48                 :            : 
      49                 :            : PyDoc_STRVAR(_contextvars_Context_items__doc__,
      50                 :            : "items($self, /)\n"
      51                 :            : "--\n"
      52                 :            : "\n"
      53                 :            : "Return all variables and their values in the context object.\n"
      54                 :            : "\n"
      55                 :            : "The result is returned as a list of 2-tuples (variable, value).");
      56                 :            : 
      57                 :            : #define _CONTEXTVARS_CONTEXT_ITEMS_METHODDEF    \
      58                 :            :     {"items", (PyCFunction)_contextvars_Context_items, METH_NOARGS, _contextvars_Context_items__doc__},
      59                 :            : 
      60                 :            : static PyObject *
      61                 :            : _contextvars_Context_items_impl(PyContext *self);
      62                 :            : 
      63                 :            : static PyObject *
      64                 :          0 : _contextvars_Context_items(PyContext *self, PyObject *Py_UNUSED(ignored))
      65                 :            : {
      66                 :          0 :     return _contextvars_Context_items_impl(self);
      67                 :            : }
      68                 :            : 
      69                 :            : PyDoc_STRVAR(_contextvars_Context_keys__doc__,
      70                 :            : "keys($self, /)\n"
      71                 :            : "--\n"
      72                 :            : "\n"
      73                 :            : "Return a list of all variables in the context object.");
      74                 :            : 
      75                 :            : #define _CONTEXTVARS_CONTEXT_KEYS_METHODDEF    \
      76                 :            :     {"keys", (PyCFunction)_contextvars_Context_keys, METH_NOARGS, _contextvars_Context_keys__doc__},
      77                 :            : 
      78                 :            : static PyObject *
      79                 :            : _contextvars_Context_keys_impl(PyContext *self);
      80                 :            : 
      81                 :            : static PyObject *
      82                 :          0 : _contextvars_Context_keys(PyContext *self, PyObject *Py_UNUSED(ignored))
      83                 :            : {
      84                 :          0 :     return _contextvars_Context_keys_impl(self);
      85                 :            : }
      86                 :            : 
      87                 :            : PyDoc_STRVAR(_contextvars_Context_values__doc__,
      88                 :            : "values($self, /)\n"
      89                 :            : "--\n"
      90                 :            : "\n"
      91                 :            : "Return a list of all variables\' values in the context object.");
      92                 :            : 
      93                 :            : #define _CONTEXTVARS_CONTEXT_VALUES_METHODDEF    \
      94                 :            :     {"values", (PyCFunction)_contextvars_Context_values, METH_NOARGS, _contextvars_Context_values__doc__},
      95                 :            : 
      96                 :            : static PyObject *
      97                 :            : _contextvars_Context_values_impl(PyContext *self);
      98                 :            : 
      99                 :            : static PyObject *
     100                 :          0 : _contextvars_Context_values(PyContext *self, PyObject *Py_UNUSED(ignored))
     101                 :            : {
     102                 :          0 :     return _contextvars_Context_values_impl(self);
     103                 :            : }
     104                 :            : 
     105                 :            : PyDoc_STRVAR(_contextvars_Context_copy__doc__,
     106                 :            : "copy($self, /)\n"
     107                 :            : "--\n"
     108                 :            : "\n"
     109                 :            : "Return a shallow copy of the context object.");
     110                 :            : 
     111                 :            : #define _CONTEXTVARS_CONTEXT_COPY_METHODDEF    \
     112                 :            :     {"copy", (PyCFunction)_contextvars_Context_copy, METH_NOARGS, _contextvars_Context_copy__doc__},
     113                 :            : 
     114                 :            : static PyObject *
     115                 :            : _contextvars_Context_copy_impl(PyContext *self);
     116                 :            : 
     117                 :            : static PyObject *
     118                 :          0 : _contextvars_Context_copy(PyContext *self, PyObject *Py_UNUSED(ignored))
     119                 :            : {
     120                 :          0 :     return _contextvars_Context_copy_impl(self);
     121                 :            : }
     122                 :            : 
     123                 :            : PyDoc_STRVAR(_contextvars_ContextVar_get__doc__,
     124                 :            : "get($self, default=<unrepresentable>, /)\n"
     125                 :            : "--\n"
     126                 :            : "\n"
     127                 :            : "Return a value for the context variable for the current context.\n"
     128                 :            : "\n"
     129                 :            : "If there is no value for the variable in the current context, the method will:\n"
     130                 :            : " * return the value of the default argument of the method, if provided; or\n"
     131                 :            : " * return the default value for the context variable, if it was created\n"
     132                 :            : "   with one; or\n"
     133                 :            : " * raise a LookupError.");
     134                 :            : 
     135                 :            : #define _CONTEXTVARS_CONTEXTVAR_GET_METHODDEF    \
     136                 :            :     {"get", _PyCFunction_CAST(_contextvars_ContextVar_get), METH_FASTCALL, _contextvars_ContextVar_get__doc__},
     137                 :            : 
     138                 :            : static PyObject *
     139                 :            : _contextvars_ContextVar_get_impl(PyContextVar *self, PyObject *default_value);
     140                 :            : 
     141                 :            : static PyObject *
     142                 :          0 : _contextvars_ContextVar_get(PyContextVar *self, PyObject *const *args, Py_ssize_t nargs)
     143                 :            : {
     144                 :          0 :     PyObject *return_value = NULL;
     145                 :          0 :     PyObject *default_value = NULL;
     146                 :            : 
     147   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("get", nargs, 0, 1)) {
                   #  # ]
     148                 :          0 :         goto exit;
     149                 :            :     }
     150         [ #  # ]:          0 :     if (nargs < 1) {
     151                 :          0 :         goto skip_optional;
     152                 :            :     }
     153                 :          0 :     default_value = args[0];
     154                 :          0 : skip_optional:
     155                 :          0 :     return_value = _contextvars_ContextVar_get_impl(self, default_value);
     156                 :            : 
     157                 :          0 : exit:
     158                 :          0 :     return return_value;
     159                 :            : }
     160                 :            : 
     161                 :            : PyDoc_STRVAR(_contextvars_ContextVar_set__doc__,
     162                 :            : "set($self, value, /)\n"
     163                 :            : "--\n"
     164                 :            : "\n"
     165                 :            : "Call to set a new value for the context variable in the current context.\n"
     166                 :            : "\n"
     167                 :            : "The required value argument is the new value for the context variable.\n"
     168                 :            : "\n"
     169                 :            : "Returns a Token object that can be used to restore the variable to its previous\n"
     170                 :            : "value via the `ContextVar.reset()` method.");
     171                 :            : 
     172                 :            : #define _CONTEXTVARS_CONTEXTVAR_SET_METHODDEF    \
     173                 :            :     {"set", (PyCFunction)_contextvars_ContextVar_set, METH_O, _contextvars_ContextVar_set__doc__},
     174                 :            : 
     175                 :            : PyDoc_STRVAR(_contextvars_ContextVar_reset__doc__,
     176                 :            : "reset($self, token, /)\n"
     177                 :            : "--\n"
     178                 :            : "\n"
     179                 :            : "Reset the context variable.\n"
     180                 :            : "\n"
     181                 :            : "The variable is reset to the value it had before the `ContextVar.set()` that\n"
     182                 :            : "created the token was used.");
     183                 :            : 
     184                 :            : #define _CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF    \
     185                 :            :     {"reset", (PyCFunction)_contextvars_ContextVar_reset, METH_O, _contextvars_ContextVar_reset__doc__},
     186                 :            : /*[clinic end generated code: output=0c94d4b919500438 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14