summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Python/clinic/bltinmodule.c.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/tools/python3/Python/clinic/bltinmodule.c.h')
-rw-r--r--contrib/tools/python3/Python/clinic/bltinmodule.c.h332
1 files changed, 80 insertions, 252 deletions
diff --git a/contrib/tools/python3/Python/clinic/bltinmodule.c.h b/contrib/tools/python3/Python/clinic/bltinmodule.c.h
index b77b4a1e4b4..370cf3c929b 100644
--- a/contrib/tools/python3/Python/clinic/bltinmodule.c.h
+++ b/contrib/tools/python3/Python/clinic/bltinmodule.c.h
@@ -3,10 +3,10 @@ preserve
[clinic start generated code]*/
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
-# include "pycore_gc.h" // PyGC_Head
-# include "pycore_runtime.h" // _Py_ID()
+# include "pycore_gc.h" // PyGC_Head
+# include "pycore_runtime.h" // _Py_ID()
#endif
-
+#include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
PyDoc_STRVAR(builtin___import____doc__,
"__import__($module, /, name, globals=None, locals=None, fromlist=(),\n"
@@ -99,7 +99,7 @@ builtin___import__(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py
goto skip_optional_pos;
}
}
- level = _PyLong_AsInt(args[4]);
+ level = PyLong_AsInt(args[4]);
if (level == -1 && PyErr_Occurred()) {
goto exit;
}
@@ -216,9 +216,6 @@ builtin_format(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
_PyArg_BadArgument("format", "argument 2", "str", args[1]);
goto exit;
}
- if (PyUnicode_READY(args[1]) == -1) {
- goto exit;
- }
format_spec = args[1];
skip_optional:
return_value = builtin_format_impl(module, value, format_spec);
@@ -236,25 +233,6 @@ PyDoc_STRVAR(builtin_chr__doc__,
#define BUILTIN_CHR_METHODDEF \
{"chr", (PyCFunction)builtin_chr, METH_O, builtin_chr__doc__},
-static PyObject *
-builtin_chr_impl(PyObject *module, int i);
-
-static PyObject *
-builtin_chr(PyObject *module, PyObject *arg)
-{
- PyObject *return_value = NULL;
- int i;
-
- i = _PyLong_AsInt(arg);
- if (i == -1 && PyErr_Occurred()) {
- goto exit;
- }
- return_value = builtin_chr_impl(module, i);
-
-exit:
- return return_value;
-}
-
PyDoc_STRVAR(builtin_compile__doc__,
"compile($module, /, source, filename, mode, flags=0,\n"
" dont_inherit=False, optimize=-1, *, _feature_version=-1)\n"
@@ -313,7 +291,7 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj
PyObject *argsbuf[7];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
PyObject *source;
- PyObject *filename;
+ PyObject *filename = NULL;
const char *mode;
int flags = 0;
int dont_inherit = 0;
@@ -345,7 +323,7 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj
goto skip_optional_pos;
}
if (args[3]) {
- flags = _PyLong_AsInt(args[3]);
+ flags = PyLong_AsInt(args[3]);
if (flags == -1 && PyErr_Occurred()) {
goto exit;
}
@@ -363,7 +341,7 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj
}
}
if (args[5]) {
- optimize = _PyLong_AsInt(args[5]);
+ optimize = PyLong_AsInt(args[5]);
if (optimize == -1 && PyErr_Occurred()) {
goto exit;
}
@@ -375,7 +353,7 @@ skip_optional_pos:
if (!noptargs) {
goto skip_optional_kwonly;
}
- feature_version = _PyLong_AsInt(args[6]);
+ feature_version = PyLong_AsInt(args[6]);
if (feature_version == -1 && PyErr_Occurred()) {
goto exit;
}
@@ -383,49 +361,9 @@ skip_optional_kwonly:
return_value = builtin_compile_impl(module, source, filename, mode, flags, dont_inherit, optimize, feature_version);
exit:
- return return_value;
-}
+ /* Cleanup for filename */
+ Py_XDECREF(filename);
-PyDoc_STRVAR(builtin_dir__doc__,
-"dir($module, arg=<unrepresentable>, /)\n"
-"--\n"
-"\n"
-"Show attributes of an object.\n"
-"\n"
-"If called without an argument, return the names in the current scope.\n"
-"Else, return an alphabetized list of names comprising (some of) the attributes\n"
-"of the given object, and of attributes reachable from it.\n"
-"If the object supplies a method named __dir__, it will be used; otherwise\n"
-"the default dir() logic is used and returns:\n"
-" for a module object: the module\'s attributes.\n"
-" for a class object: its attributes, and recursively the attributes\n"
-" of its bases.\n"
-" for any other object: its attributes, its class\'s attributes, and\n"
-" recursively the attributes of its class\'s base classes.");
-
-#define BUILTIN_DIR_METHODDEF \
- {"dir", _PyCFunction_CAST(builtin_dir), METH_FASTCALL, builtin_dir__doc__},
-
-static PyObject *
-builtin_dir_impl(PyObject *module, PyObject *arg);
-
-static PyObject *
-builtin_dir(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
-{
- PyObject *return_value = NULL;
- PyObject *arg = NULL;
-
- if (!_PyArg_CheckPositional("dir", nargs, 0, 1)) {
- goto exit;
- }
- if (nargs < 1) {
- goto skip_optional;
- }
- arg = args[0];
-skip_optional:
- return_value = builtin_dir_impl(module, arg);
-
-exit:
return return_value;
}
@@ -460,7 +398,7 @@ exit:
}
PyDoc_STRVAR(builtin_eval__doc__,
-"eval($module, source, globals=None, locals=None, /)\n"
+"eval($module, source, /, globals=None, locals=None)\n"
"--\n"
"\n"
"Evaluate the given source in the context of globals and locals.\n"
@@ -472,33 +410,63 @@ PyDoc_STRVAR(builtin_eval__doc__,
"If only globals is given, locals defaults to it.");
#define BUILTIN_EVAL_METHODDEF \
- {"eval", _PyCFunction_CAST(builtin_eval), METH_FASTCALL, builtin_eval__doc__},
+ {"eval", _PyCFunction_CAST(builtin_eval), METH_FASTCALL|METH_KEYWORDS, builtin_eval__doc__},
static PyObject *
builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals,
PyObject *locals);
static PyObject *
-builtin_eval(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+builtin_eval(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
+ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
+
+ #define NUM_KEYWORDS 2
+ static struct {
+ PyGC_Head _this_is_not_used;
+ PyObject_VAR_HEAD
+ PyObject *ob_item[NUM_KEYWORDS];
+ } _kwtuple = {
+ .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
+ .ob_item = { &_Py_ID(globals), &_Py_ID(locals), },
+ };
+ #undef NUM_KEYWORDS
+ #define KWTUPLE (&_kwtuple.ob_base.ob_base)
+
+ #else // !Py_BUILD_CORE
+ # define KWTUPLE NULL
+ #endif // !Py_BUILD_CORE
+
+ static const char * const _keywords[] = {"", "globals", "locals", NULL};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "eval",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
+ PyObject *argsbuf[3];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *source;
PyObject *globals = Py_None;
PyObject *locals = Py_None;
- if (!_PyArg_CheckPositional("eval", nargs, 1, 3)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf);
+ if (!args) {
goto exit;
}
source = args[0];
- if (nargs < 2) {
- goto skip_optional;
+ if (!noptargs) {
+ goto skip_optional_pos;
}
- globals = args[1];
- if (nargs < 3) {
- goto skip_optional;
+ if (args[1]) {
+ globals = args[1];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
}
locals = args[2];
-skip_optional:
+skip_optional_pos:
return_value = builtin_eval_impl(module, source, globals, locals);
exit:
@@ -506,7 +474,7 @@ exit:
}
PyDoc_STRVAR(builtin_exec__doc__,
-"exec($module, source, globals=None, locals=None, /, *, closure=None)\n"
+"exec($module, source, /, globals=None, locals=None, *, closure=None)\n"
"--\n"
"\n"
"Execute the given source in the context of globals and locals.\n"
@@ -532,14 +500,14 @@ builtin_exec(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
+ #define NUM_KEYWORDS 3
static struct {
PyGC_Head _this_is_not_used;
PyObject_VAR_HEAD
PyObject *ob_item[NUM_KEYWORDS];
} _kwtuple = {
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(closure), },
+ .ob_item = { &_Py_ID(globals), &_Py_ID(locals), &_Py_ID(closure), },
};
#undef NUM_KEYWORDS
#define KWTUPLE (&_kwtuple.ob_base.ob_base)
@@ -548,7 +516,7 @@ builtin_exec(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
# define KWTUPLE NULL
#endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"", "", "", "closure", NULL};
+ static const char * const _keywords[] = {"", "globals", "locals", "closure", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "exec",
@@ -567,17 +535,22 @@ builtin_exec(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
goto exit;
}
source = args[0];
- if (nargs < 2) {
- goto skip_optional_posonly;
+ if (!noptargs) {
+ goto skip_optional_pos;
}
- noptargs--;
- globals = args[1];
- if (nargs < 3) {
- goto skip_optional_posonly;
+ if (args[1]) {
+ globals = args[1];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
}
- noptargs--;
- locals = args[2];
-skip_optional_posonly:
+ if (args[2]) {
+ locals = args[2];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+skip_optional_pos:
if (!noptargs) {
goto skip_optional_kwonly;
}
@@ -589,47 +562,6 @@ exit:
return return_value;
}
-PyDoc_STRVAR(builtin_getattr__doc__,
-"getattr($module, object, name, default=<unrepresentable>, /)\n"
-"--\n"
-"\n"
-"Get a named attribute from an object.\n"
-"\n"
-"getattr(x, \'y\') is equivalent to x.y\n"
-"When a default argument is given, it is returned when the attribute doesn\'t\n"
-"exist; without it, an exception is raised in that case.");
-
-#define BUILTIN_GETATTR_METHODDEF \
- {"getattr", _PyCFunction_CAST(builtin_getattr), METH_FASTCALL, builtin_getattr__doc__},
-
-static PyObject *
-builtin_getattr_impl(PyObject *module, PyObject *object, PyObject *name,
- PyObject *default_value);
-
-static PyObject *
-builtin_getattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
-{
- PyObject *return_value = NULL;
- PyObject *object;
- PyObject *name;
- PyObject *default_value = NULL;
-
- if (!_PyArg_CheckPositional("getattr", nargs, 2, 3)) {
- goto exit;
- }
- object = args[0];
- name = args[1];
- if (nargs < 3) {
- goto skip_optional;
- }
- default_value = args[2];
-skip_optional:
- return_value = builtin_getattr_impl(module, object, name, default_value);
-
-exit:
- return return_value;
-}
-
PyDoc_STRVAR(builtin_globals__doc__,
"globals($module, /)\n"
"--\n"
@@ -695,44 +627,6 @@ PyDoc_STRVAR(builtin_id__doc__,
#define BUILTIN_ID_METHODDEF \
{"id", (PyCFunction)builtin_id, METH_O, builtin_id__doc__},
-PyDoc_STRVAR(builtin_next__doc__,
-"next($module, iterator, default=<unrepresentable>, /)\n"
-"--\n"
-"\n"
-"Return the next item from the iterator.\n"
-"\n"
-"If default is given and the iterator is exhausted,\n"
-"it is returned instead of raising StopIteration.");
-
-#define BUILTIN_NEXT_METHODDEF \
- {"next", _PyCFunction_CAST(builtin_next), METH_FASTCALL, builtin_next__doc__},
-
-static PyObject *
-builtin_next_impl(PyObject *module, PyObject *iterator,
- PyObject *default_value);
-
-static PyObject *
-builtin_next(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
-{
- PyObject *return_value = NULL;
- PyObject *iterator;
- PyObject *default_value = NULL;
-
- if (!_PyArg_CheckPositional("next", nargs, 1, 2)) {
- goto exit;
- }
- iterator = args[0];
- if (nargs < 2) {
- goto skip_optional;
- }
- default_value = args[1];
-skip_optional:
- return_value = builtin_next_impl(module, iterator, default_value);
-
-exit:
- return return_value;
-}
-
PyDoc_STRVAR(builtin_setattr__doc__,
"setattr($module, obj, name, value, /)\n"
"--\n"
@@ -824,43 +718,6 @@ PyDoc_STRVAR(builtin_hex__doc__,
#define BUILTIN_HEX_METHODDEF \
{"hex", (PyCFunction)builtin_hex, METH_O, builtin_hex__doc__},
-PyDoc_STRVAR(builtin_iter__doc__,
-"iter($module, object, sentinel=<unrepresentable>, /)\n"
-"--\n"
-"\n"
-"Get an iterator from an object.\n"
-"\n"
-"In the first form, the argument must supply its own iterator, or be a sequence.\n"
-"In the second form, the callable is called until it returns the sentinel.");
-
-#define BUILTIN_ITER_METHODDEF \
- {"iter", _PyCFunction_CAST(builtin_iter), METH_FASTCALL, builtin_iter__doc__},
-
-static PyObject *
-builtin_iter_impl(PyObject *module, PyObject *object, PyObject *sentinel);
-
-static PyObject *
-builtin_iter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
-{
- PyObject *return_value = NULL;
- PyObject *object;
- PyObject *sentinel = NULL;
-
- if (!_PyArg_CheckPositional("iter", nargs, 1, 2)) {
- goto exit;
- }
- object = args[0];
- if (nargs < 2) {
- goto skip_optional;
- }
- sentinel = args[1];
-skip_optional:
- return_value = builtin_iter_impl(module, object, sentinel);
-
-exit:
- return return_value;
-}
-
PyDoc_STRVAR(builtin_aiter__doc__,
"aiter($module, async_iterable, /)\n"
"--\n"
@@ -874,10 +731,10 @@ PyDoc_STRVAR(builtin_anext__doc__,
"anext($module, aiterator, default=<unrepresentable>, /)\n"
"--\n"
"\n"
-"async anext(aiterator[, default])\n"
+"Return the next item from the async iterator.\n"
"\n"
-"Return the next item from the async iterator. If default is given and the async\n"
-"iterator is exhausted, it is returned instead of raising StopAsyncIteration.");
+"If default is given and the async iterator is exhausted,\n"
+"it is returned instead of raising StopAsyncIteration.");
#define BUILTIN_ANEXT_METHODDEF \
{"anext", _PyCFunction_CAST(builtin_anext), METH_FASTCALL, builtin_anext__doc__},
@@ -952,10 +809,16 @@ PyDoc_STRVAR(builtin_oct__doc__,
{"oct", (PyCFunction)builtin_oct, METH_O, builtin_oct__doc__},
PyDoc_STRVAR(builtin_ord__doc__,
-"ord($module, c, /)\n"
+"ord($module, character, /)\n"
"--\n"
"\n"
-"Return the Unicode code point for a one-character string.");
+"Return the ordinal value of a character.\n"
+"\n"
+"If the argument is a one-character string, return the Unicode code\n"
+"point of that character.\n"
+"\n"
+"If the argument is a bytes or bytearray object of length 1, return its\n"
+"single byte value.");
#define BUILTIN_ORD_METHODDEF \
{"ord", (PyCFunction)builtin_ord, METH_O, builtin_ord__doc__},
@@ -1239,41 +1102,6 @@ exit:
return return_value;
}
-PyDoc_STRVAR(builtin_vars__doc__,
-"vars($module, object=<unrepresentable>, /)\n"
-"--\n"
-"\n"
-"Show vars.\n"
-"\n"
-"Without arguments, equivalent to locals().\n"
-"With an argument, equivalent to object.__dict__.");
-
-#define BUILTIN_VARS_METHODDEF \
- {"vars", _PyCFunction_CAST(builtin_vars), METH_FASTCALL, builtin_vars__doc__},
-
-static PyObject *
-builtin_vars_impl(PyObject *module, PyObject *object);
-
-static PyObject *
-builtin_vars(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
-{
- PyObject *return_value = NULL;
- PyObject *object = NULL;
-
- if (!_PyArg_CheckPositional("vars", nargs, 0, 1)) {
- goto exit;
- }
- if (nargs < 1) {
- goto skip_optional;
- }
- object = args[0];
-skip_optional:
- return_value = builtin_vars_impl(module, object);
-
-exit:
- return return_value;
-}
-
PyDoc_STRVAR(builtin_sum__doc__,
"sum($module, iterable, /, start=0)\n"
"--\n"
@@ -1409,4 +1237,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=84a04e7446debf58 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=39173c70790d9cd0 input=a9049054013a1b77]*/