cpython/Modules/clinic/_randommodule.c.h
Victor Stinner be5e8a0103
gh-110964: Remove private _PyArg functions (#110966)
Move the following private functions and structures to
pycore_modsupport.h internal C API:

* _PyArg_BadArgument()
* _PyArg_CheckPositional()
* _PyArg_NoKeywords()
* _PyArg_NoPositional()
* _PyArg_ParseStack()
* _PyArg_ParseStackAndKeywords()
* _PyArg_Parser structure
* _PyArg_UnpackKeywords()
* _PyArg_UnpackKeywordsWithVararg()
* _PyArg_UnpackStack()
* _Py_ANY_VARARGS()

Changes:

* Python/getargs.h now includes pycore_modsupport.h to export
  functions.
* clinic.py now adds pycore_modsupport.h when one of these functions
  is used.
* Add pycore_modsupport.h includes when a C extension uses one of
  these functions.
* Define Py_BUILD_CORE_MODULE in C extensions which now include
  directly or indirectly (via code generated by Argument Clinic)
  pycore_modsupport.h:

  * _csv
  * _curses_panel
  * _dbm
  * _gdbm
  * _multiprocessing.posixshmem
  * _sqlite.row
  * _statistics
  * grp
  * resource
  * syslog

* _testcapi: bad_get() no longer uses METH_FASTCALL calling
  convention but METH_VARARGS. Replace _PyArg_UnpackStack() with
  PyArg_ParseTuple().
* _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined
  by _testcapi sub-modules which need the internal C API
  (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c,
  watchers.c.
* Remove Include/cpython/modsupport.h header file.
  Include/modsupport.h no longer includes the removed header file.
* Fix mypy clinic.py
2023-10-17 14:30:31 +02:00

114 lines
2.9 KiB
C
Generated

/*[clinic input]
preserve
[clinic start generated code]*/
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
PyDoc_STRVAR(_random_Random_random__doc__,
"random($self, /)\n"
"--\n"
"\n"
"random() -> x in the interval [0, 1).");
#define _RANDOM_RANDOM_RANDOM_METHODDEF \
{"random", (PyCFunction)_random_Random_random, METH_NOARGS, _random_Random_random__doc__},
static PyObject *
_random_Random_random_impl(RandomObject *self);
static PyObject *
_random_Random_random(RandomObject *self, PyObject *Py_UNUSED(ignored))
{
return _random_Random_random_impl(self);
}
PyDoc_STRVAR(_random_Random_seed__doc__,
"seed($self, n=None, /)\n"
"--\n"
"\n"
"seed([n]) -> None.\n"
"\n"
"Defaults to use urandom and falls back to a combination\n"
"of the current time and the process identifier.");
#define _RANDOM_RANDOM_SEED_METHODDEF \
{"seed", _PyCFunction_CAST(_random_Random_seed), METH_FASTCALL, _random_Random_seed__doc__},
static PyObject *
_random_Random_seed_impl(RandomObject *self, PyObject *n);
static PyObject *
_random_Random_seed(RandomObject *self, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *n = Py_None;
if (!_PyArg_CheckPositional("seed", nargs, 0, 1)) {
goto exit;
}
if (nargs < 1) {
goto skip_optional;
}
n = args[0];
skip_optional:
return_value = _random_Random_seed_impl(self, n);
exit:
return return_value;
}
PyDoc_STRVAR(_random_Random_getstate__doc__,
"getstate($self, /)\n"
"--\n"
"\n"
"getstate() -> tuple containing the current state.");
#define _RANDOM_RANDOM_GETSTATE_METHODDEF \
{"getstate", (PyCFunction)_random_Random_getstate, METH_NOARGS, _random_Random_getstate__doc__},
static PyObject *
_random_Random_getstate_impl(RandomObject *self);
static PyObject *
_random_Random_getstate(RandomObject *self, PyObject *Py_UNUSED(ignored))
{
return _random_Random_getstate_impl(self);
}
PyDoc_STRVAR(_random_Random_setstate__doc__,
"setstate($self, state, /)\n"
"--\n"
"\n"
"setstate(state) -> None. Restores generator state.");
#define _RANDOM_RANDOM_SETSTATE_METHODDEF \
{"setstate", (PyCFunction)_random_Random_setstate, METH_O, _random_Random_setstate__doc__},
PyDoc_STRVAR(_random_Random_getrandbits__doc__,
"getrandbits($self, k, /)\n"
"--\n"
"\n"
"getrandbits(k) -> x. Generates an int with k random bits.");
#define _RANDOM_RANDOM_GETRANDBITS_METHODDEF \
{"getrandbits", (PyCFunction)_random_Random_getrandbits, METH_O, _random_Random_getrandbits__doc__},
static PyObject *
_random_Random_getrandbits_impl(RandomObject *self, int k);
static PyObject *
_random_Random_getrandbits(RandomObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
int k;
k = PyLong_AsInt(arg);
if (k == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = _random_Random_getrandbits_impl(self, k);
exit:
return return_value;
}
/*[clinic end generated code: output=5c800a28c2d7b9d1 input=a9049054013a1b77]*/