aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Python/clinic
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committerDaniil Cherednik <dcherednik@ydb.tech>2024-02-14 14:26:16 +0000
commit31f2a419764a8ba77c2a970cfc80056c6cd06756 (patch)
treec1995d239eba8571cefc640f6648e1d5dd4ce9e2 /contrib/tools/python3/src/Python/clinic
parentfe2ef02b38d9c85d80060963b265a1df9f38c3bb (diff)
downloadydb-31f2a419764a8ba77c2a970cfc80056c6cd06756.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Python/clinic')
-rw-r--r--contrib/tools/python3/src/Python/clinic/Python-tokenize.c.h70
-rw-r--r--contrib/tools/python3/src/Python/clinic/_warnings.c.h198
-rw-r--r--contrib/tools/python3/src/Python/clinic/bltinmodule.c.h392
-rw-r--r--contrib/tools/python3/src/Python/clinic/context.c.h8
-rw-r--r--contrib/tools/python3/src/Python/clinic/import.c.h89
-rw-r--r--contrib/tools/python3/src/Python/clinic/instrumentation.c.h311
-rw-r--r--contrib/tools/python3/src/Python/clinic/marshal.c.h8
-rw-r--r--contrib/tools/python3/src/Python/clinic/sysmodule.c.h388
-rw-r--r--contrib/tools/python3/src/Python/clinic/traceback.c.h33
9 files changed, 1433 insertions, 64 deletions
diff --git a/contrib/tools/python3/src/Python/clinic/Python-tokenize.c.h b/contrib/tools/python3/src/Python/clinic/Python-tokenize.c.h
index 050b4d4944..28f5075826 100644
--- a/contrib/tools/python3/src/Python/clinic/Python-tokenize.c.h
+++ b/contrib/tools/python3/src/Python/clinic/Python-tokenize.c.h
@@ -2,40 +2,82 @@
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()
+#endif
+
+
static PyObject *
-tokenizeriter_new_impl(PyTypeObject *type, const char *source);
+tokenizeriter_new_impl(PyTypeObject *type, PyObject *readline,
+ int extra_tokens, const char *encoding);
static PyObject *
tokenizeriter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
- static const char * const _keywords[] = {"source", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "tokenizeriter", 0};
- PyObject *argsbuf[1];
+ #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(extra_tokens), &_Py_ID(encoding), },
+ };
+ #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[] = {"", "extra_tokens", "encoding", NULL};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "tokenizeriter",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
+ PyObject *argsbuf[3];
PyObject * const *fastargs;
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
- const char *source;
+ Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2;
+ PyObject *readline;
+ int extra_tokens;
+ const char *encoding = NULL;
- fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf);
+ fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 1, argsbuf);
if (!fastargs) {
goto exit;
}
- if (!PyUnicode_Check(fastargs[0])) {
- _PyArg_BadArgument("tokenizeriter", "argument 'source'", "str", fastargs[0]);
+ readline = fastargs[0];
+ extra_tokens = PyObject_IsTrue(fastargs[1]);
+ if (extra_tokens < 0) {
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_kwonly;
+ }
+ if (!PyUnicode_Check(fastargs[2])) {
+ _PyArg_BadArgument("tokenizeriter", "argument 'encoding'", "str", fastargs[2]);
goto exit;
}
- Py_ssize_t source_length;
- source = PyUnicode_AsUTF8AndSize(fastargs[0], &source_length);
- if (source == NULL) {
+ Py_ssize_t encoding_length;
+ encoding = PyUnicode_AsUTF8AndSize(fastargs[2], &encoding_length);
+ if (encoding == NULL) {
goto exit;
}
- if (strlen(source) != (size_t)source_length) {
+ if (strlen(encoding) != (size_t)encoding_length) {
PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit;
}
- return_value = tokenizeriter_new_impl(type, source);
+skip_optional_kwonly:
+ return_value = tokenizeriter_new_impl(type, readline, extra_tokens, encoding);
exit:
return return_value;
}
-/*[clinic end generated code: output=dfcd64774e01bfe6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=48be65a2808bdfa6 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Python/clinic/_warnings.c.h b/contrib/tools/python3/src/Python/clinic/_warnings.c.h
index aa85c2a0d4..432e554af8 100644
--- a/contrib/tools/python3/src/Python/clinic/_warnings.c.h
+++ b/contrib/tools/python3/src/Python/clinic/_warnings.c.h
@@ -2,31 +2,76 @@
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()
+#endif
+
+
PyDoc_STRVAR(warnings_warn__doc__,
-"warn($module, /, message, category=None, stacklevel=1, source=None)\n"
+"warn($module, /, message, category=None, stacklevel=1, source=None, *,\n"
+" skip_file_prefixes=<unrepresentable>)\n"
"--\n"
"\n"
-"Issue a warning, or maybe ignore it or raise an exception.");
+"Issue a warning, or maybe ignore it or raise an exception.\n"
+"\n"
+" message\n"
+" Text of the warning message.\n"
+" category\n"
+" The Warning category subclass. Defaults to UserWarning.\n"
+" stacklevel\n"
+" How far up the call stack to make this warning appear. A value of 2 for\n"
+" example attributes the warning to the caller of the code calling warn().\n"
+" source\n"
+" If supplied, the destroyed object which emitted a ResourceWarning\n"
+" skip_file_prefixes\n"
+" An optional tuple of module filename prefixes indicating frames to skip\n"
+" during stacklevel computations for stack frame attribution.");
#define WARNINGS_WARN_METHODDEF \
{"warn", _PyCFunction_CAST(warnings_warn), METH_FASTCALL|METH_KEYWORDS, warnings_warn__doc__},
static PyObject *
warnings_warn_impl(PyObject *module, PyObject *message, PyObject *category,
- Py_ssize_t stacklevel, PyObject *source);
+ Py_ssize_t stacklevel, PyObject *source,
+ PyTupleObject *skip_file_prefixes);
static PyObject *
warnings_warn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
- static const char * const _keywords[] = {"message", "category", "stacklevel", "source", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "warn", 0};
- PyObject *argsbuf[4];
+ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
+
+ #define NUM_KEYWORDS 5
+ 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(message), &_Py_ID(category), &_Py_ID(stacklevel), &_Py_ID(source), &_Py_ID(skip_file_prefixes), },
+ };
+ #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[] = {"message", "category", "stacklevel", "source", "skip_file_prefixes", NULL};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "warn",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
+ PyObject *argsbuf[5];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *message;
PyObject *category = Py_None;
Py_ssize_t stacklevel = 1;
PyObject *source = Py_None;
+ PyTupleObject *skip_file_prefixes = NULL;
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 4, 0, argsbuf);
if (!args) {
@@ -59,11 +104,146 @@ warnings_warn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec
goto skip_optional_pos;
}
}
- source = args[3];
+ if (args[3]) {
+ source = args[3];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+skip_optional_pos:
+ if (!noptargs) {
+ goto skip_optional_kwonly;
+ }
+ if (!PyTuple_Check(args[4])) {
+ _PyArg_BadArgument("warn", "argument 'skip_file_prefixes'", "tuple", args[4]);
+ goto exit;
+ }
+ skip_file_prefixes = (PyTupleObject *)args[4];
+skip_optional_kwonly:
+ return_value = warnings_warn_impl(module, message, category, stacklevel, source, skip_file_prefixes);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(warnings_warn_explicit__doc__,
+"warn_explicit($module, /, message, category, filename, lineno,\n"
+" module=<unrepresentable>, registry=None,\n"
+" module_globals=None, source=None)\n"
+"--\n"
+"\n"
+"Issue a warning, or maybe ignore it or raise an exception.");
+
+#define WARNINGS_WARN_EXPLICIT_METHODDEF \
+ {"warn_explicit", _PyCFunction_CAST(warnings_warn_explicit), METH_FASTCALL|METH_KEYWORDS, warnings_warn_explicit__doc__},
+
+static PyObject *
+warnings_warn_explicit_impl(PyObject *module, PyObject *message,
+ PyObject *category, PyObject *filename,
+ int lineno, PyObject *mod, PyObject *registry,
+ PyObject *module_globals, PyObject *sourceobj);
+
+static PyObject *
+warnings_warn_explicit(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 8
+ 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(message), &_Py_ID(category), &_Py_ID(filename), &_Py_ID(lineno), &_Py_ID(module), &_Py_ID(registry), &_Py_ID(module_globals), &_Py_ID(source), },
+ };
+ #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[] = {"message", "category", "filename", "lineno", "module", "registry", "module_globals", "source", NULL};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "warn_explicit",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
+ PyObject *argsbuf[8];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4;
+ PyObject *message;
+ PyObject *category;
+ PyObject *filename;
+ int lineno;
+ PyObject *mod = NULL;
+ PyObject *registry = Py_None;
+ PyObject *module_globals = Py_None;
+ PyObject *sourceobj = Py_None;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 8, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ message = args[0];
+ category = args[1];
+ if (!PyUnicode_Check(args[2])) {
+ _PyArg_BadArgument("warn_explicit", "argument 'filename'", "str", args[2]);
+ goto exit;
+ }
+ if (PyUnicode_READY(args[2]) == -1) {
+ goto exit;
+ }
+ filename = args[2];
+ lineno = _PyLong_AsInt(args[3]);
+ if (lineno == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[4]) {
+ mod = args[4];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ if (args[5]) {
+ registry = args[5];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ if (args[6]) {
+ module_globals = args[6];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ sourceobj = args[7];
skip_optional_pos:
- return_value = warnings_warn_impl(module, message, category, stacklevel, source);
+ return_value = warnings_warn_explicit_impl(module, message, category, filename, lineno, mod, registry, module_globals, sourceobj);
exit:
return return_value;
}
-/*[clinic end generated code: output=0435c68611fa2fe9 input=a9049054013a1b77]*/
+
+PyDoc_STRVAR(warnings_filters_mutated__doc__,
+"_filters_mutated($module, /)\n"
+"--\n"
+"\n");
+
+#define WARNINGS_FILTERS_MUTATED_METHODDEF \
+ {"_filters_mutated", (PyCFunction)warnings_filters_mutated, METH_NOARGS, warnings_filters_mutated__doc__},
+
+static PyObject *
+warnings_filters_mutated_impl(PyObject *module);
+
+static PyObject *
+warnings_filters_mutated(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return warnings_filters_mutated_impl(module);
+}
+/*[clinic end generated code: output=20429719d7223bdc input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Python/clinic/bltinmodule.c.h b/contrib/tools/python3/src/Python/clinic/bltinmodule.c.h
index 10cd6c820b..b77b4a1e4b 100644
--- a/contrib/tools/python3/src/Python/clinic/bltinmodule.c.h
+++ b/contrib/tools/python3/src/Python/clinic/bltinmodule.c.h
@@ -2,6 +2,12 @@
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()
+#endif
+
+
PyDoc_STRVAR(builtin___import____doc__,
"__import__($module, /, name, globals=None, locals=None, fromlist=(),\n"
" level=0)\n"
@@ -34,8 +40,31 @@ static PyObject *
builtin___import__(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 5
+ 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(name), &_Py_ID(globals), &_Py_ID(locals), &_Py_ID(fromlist), &_Py_ID(level), },
+ };
+ #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[] = {"name", "globals", "locals", "fromlist", "level", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "__import__", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "__import__",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[5];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *name;
@@ -154,11 +183,14 @@ PyDoc_STRVAR(builtin_format__doc__,
"format($module, value, format_spec=\'\', /)\n"
"--\n"
"\n"
-"Return value.__format__(format_spec)\n"
+"Return type(value).__format__(value, format_spec)\n"
+"\n"
+"Many built-in types implement format_spec according to the\n"
+"Format Specification Mini-language. See help(\'FORMATTING\').\n"
"\n"
-"format_spec defaults to the empty string.\n"
-"See the Format Specification Mini-Language section of help(\'FORMATTING\') for\n"
-"details.");
+"If type(value) does not supply a method named __format__\n"
+"and format_spec is empty, then str(value) is returned.\n"
+"See also help(\'SPECIALMETHODS\').");
#define BUILTIN_FORMAT_METHODDEF \
{"format", _PyCFunction_CAST(builtin_format), METH_FASTCALL, builtin_format__doc__},
@@ -253,8 +285,31 @@ static PyObject *
builtin_compile(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 7
+ 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(source), &_Py_ID(filename), &_Py_ID(mode), &_Py_ID(flags), &_Py_ID(dont_inherit), &_Py_ID(optimize), &_Py_ID(_feature_version), },
+ };
+ #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[] = {"source", "filename", "mode", "flags", "dont_inherit", "optimize", "_feature_version", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "compile", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "compile",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[7];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
PyObject *source;
@@ -299,8 +354,8 @@ builtin_compile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObj
}
}
if (args[4]) {
- dont_inherit = _PyLong_AsInt(args[4]);
- if (dont_inherit == -1 && PyErr_Occurred()) {
+ dont_inherit = PyObject_IsTrue(args[4]);
+ if (dont_inherit < 0) {
goto exit;
}
if (!--noptargs) {
@@ -331,6 +386,49 @@ exit:
return return_value;
}
+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;
+}
+
PyDoc_STRVAR(builtin_divmod__doc__,
"divmod($module, x, y, /)\n"
"--\n"
@@ -432,8 +530,31 @@ static PyObject *
builtin_exec(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 1
+ 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), },
+ };
+ #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[] = {"", "", "", "closure", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "exec", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "exec",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[4];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *source;
@@ -468,6 +589,47 @@ 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"
@@ -533,6 +695,44 @@ 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"
@@ -624,6 +824,43 @@ 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"
@@ -743,8 +980,31 @@ static PyObject *
builtin_pow(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 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(base), &_Py_ID(exp), &_Py_ID(mod), },
+ };
+ #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[] = {"base", "exp", "mod", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "pow", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "pow",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[3];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2;
PyObject *base;
@@ -794,8 +1054,31 @@ static PyObject *
builtin_print(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 4
+ 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(sep), &_Py_ID(end), &_Py_ID(file), &_Py_ID(flush), },
+ };
+ #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[] = {"sep", "end", "file", "flush", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "print", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "print",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[5];
Py_ssize_t noptargs = 0 + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
PyObject *__clinic_args = NULL;
@@ -910,8 +1193,31 @@ static PyObject *
builtin_round(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(number), &_Py_ID(ndigits), },
+ };
+ #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[] = {"number", "ndigits", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "round", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "round",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[2];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *number;
@@ -933,6 +1239,41 @@ 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"
@@ -953,8 +1294,31 @@ static PyObject *
builtin_sum(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 1
+ 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(start), },
+ };
+ #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[] = {"", "start", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "sum", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "sum",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[2];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *iterable;
@@ -1045,4 +1409,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=c45d5fe414f7a8d7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=84a04e7446debf58 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Python/clinic/context.c.h b/contrib/tools/python3/src/Python/clinic/context.c.h
index 292d3f7f4f..27c375717b 100644
--- a/contrib/tools/python3/src/Python/clinic/context.c.h
+++ b/contrib/tools/python3/src/Python/clinic/context.c.h
@@ -2,6 +2,12 @@
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()
+#endif
+
+
PyDoc_STRVAR(_contextvars_Context_get__doc__,
"get($self, key, default=None, /)\n"
"--\n"
@@ -177,4 +183,4 @@ PyDoc_STRVAR(_contextvars_ContextVar_reset__doc__,
#define _CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF \
{"reset", (PyCFunction)_contextvars_ContextVar_reset, METH_O, _contextvars_ContextVar_reset__doc__},
-/*[clinic end generated code: output=2436b16a92452869 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=0c94d4b919500438 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Python/clinic/import.c.h b/contrib/tools/python3/src/Python/clinic/import.c.h
index 0451d97a72..cb74be6a42 100644
--- a/contrib/tools/python3/src/Python/clinic/import.c.h
+++ b/contrib/tools/python3/src/Python/clinic/import.c.h
@@ -2,6 +2,12 @@
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()
+#endif
+
+
PyDoc_STRVAR(_imp_lock_held__doc__,
"lock_held($module, /)\n"
"--\n"
@@ -193,8 +199,31 @@ static PyObject *
_imp_find_frozen(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 1
+ 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(withdata), },
+ };
+ #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[] = {"", "withdata", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "find_frozen", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "find_frozen",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[2];
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *name;
@@ -413,6 +442,37 @@ exit:
return return_value;
}
+PyDoc_STRVAR(_imp__override_multi_interp_extensions_check__doc__,
+"_override_multi_interp_extensions_check($module, override, /)\n"
+"--\n"
+"\n"
+"(internal-only) Override PyInterpreterConfig.check_multi_interp_extensions.\n"
+"\n"
+"(-1: \"never\", 1: \"always\", 0: no override)");
+
+#define _IMP__OVERRIDE_MULTI_INTERP_EXTENSIONS_CHECK_METHODDEF \
+ {"_override_multi_interp_extensions_check", (PyCFunction)_imp__override_multi_interp_extensions_check, METH_O, _imp__override_multi_interp_extensions_check__doc__},
+
+static PyObject *
+_imp__override_multi_interp_extensions_check_impl(PyObject *module,
+ int override);
+
+static PyObject *
+_imp__override_multi_interp_extensions_check(PyObject *module, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ int override;
+
+ override = _PyLong_AsInt(arg);
+ if (override == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ return_value = _imp__override_multi_interp_extensions_check_impl(module, override);
+
+exit:
+ return return_value;
+}
+
#if defined(HAVE_DYNAMIC_LOADING)
PyDoc_STRVAR(_imp_create_dynamic__doc__,
@@ -526,8 +586,31 @@ static PyObject *
_imp_source_hash(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(key), &_Py_ID(source), },
+ };
+ #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[] = {"key", "source", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "source_hash", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "source_hash",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[2];
long key;
Py_buffer source = {NULL, NULL};
@@ -565,4 +648,4 @@ exit:
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
-/*[clinic end generated code: output=8d0f4305b1d0714b input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b18d46e0036eff49 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Python/clinic/instrumentation.c.h b/contrib/tools/python3/src/Python/clinic/instrumentation.c.h
new file mode 100644
index 0000000000..cf3984ca24
--- /dev/null
+++ b/contrib/tools/python3/src/Python/clinic/instrumentation.c.h
@@ -0,0 +1,311 @@
+/*[clinic input]
+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()
+#endif
+
+
+PyDoc_STRVAR(monitoring_use_tool_id__doc__,
+"use_tool_id($module, tool_id, name, /)\n"
+"--\n"
+"\n");
+
+#define MONITORING_USE_TOOL_ID_METHODDEF \
+ {"use_tool_id", _PyCFunction_CAST(monitoring_use_tool_id), METH_FASTCALL, monitoring_use_tool_id__doc__},
+
+static PyObject *
+monitoring_use_tool_id_impl(PyObject *module, int tool_id, PyObject *name);
+
+static PyObject *
+monitoring_use_tool_id(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ int tool_id;
+ PyObject *name;
+
+ if (!_PyArg_CheckPositional("use_tool_id", nargs, 2, 2)) {
+ goto exit;
+ }
+ tool_id = _PyLong_AsInt(args[0]);
+ if (tool_id == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ name = args[1];
+ return_value = monitoring_use_tool_id_impl(module, tool_id, name);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(monitoring_free_tool_id__doc__,
+"free_tool_id($module, tool_id, /)\n"
+"--\n"
+"\n");
+
+#define MONITORING_FREE_TOOL_ID_METHODDEF \
+ {"free_tool_id", (PyCFunction)monitoring_free_tool_id, METH_O, monitoring_free_tool_id__doc__},
+
+static PyObject *
+monitoring_free_tool_id_impl(PyObject *module, int tool_id);
+
+static PyObject *
+monitoring_free_tool_id(PyObject *module, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ int tool_id;
+
+ tool_id = _PyLong_AsInt(arg);
+ if (tool_id == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ return_value = monitoring_free_tool_id_impl(module, tool_id);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(monitoring_get_tool__doc__,
+"get_tool($module, tool_id, /)\n"
+"--\n"
+"\n");
+
+#define MONITORING_GET_TOOL_METHODDEF \
+ {"get_tool", (PyCFunction)monitoring_get_tool, METH_O, monitoring_get_tool__doc__},
+
+static PyObject *
+monitoring_get_tool_impl(PyObject *module, int tool_id);
+
+static PyObject *
+monitoring_get_tool(PyObject *module, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ int tool_id;
+
+ tool_id = _PyLong_AsInt(arg);
+ if (tool_id == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ return_value = monitoring_get_tool_impl(module, tool_id);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(monitoring_register_callback__doc__,
+"register_callback($module, tool_id, event, func, /)\n"
+"--\n"
+"\n");
+
+#define MONITORING_REGISTER_CALLBACK_METHODDEF \
+ {"register_callback", _PyCFunction_CAST(monitoring_register_callback), METH_FASTCALL, monitoring_register_callback__doc__},
+
+static PyObject *
+monitoring_register_callback_impl(PyObject *module, int tool_id, int event,
+ PyObject *func);
+
+static PyObject *
+monitoring_register_callback(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ int tool_id;
+ int event;
+ PyObject *func;
+
+ if (!_PyArg_CheckPositional("register_callback", nargs, 3, 3)) {
+ goto exit;
+ }
+ tool_id = _PyLong_AsInt(args[0]);
+ if (tool_id == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ event = _PyLong_AsInt(args[1]);
+ if (event == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ func = args[2];
+ return_value = monitoring_register_callback_impl(module, tool_id, event, func);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(monitoring_get_events__doc__,
+"get_events($module, tool_id, /)\n"
+"--\n"
+"\n");
+
+#define MONITORING_GET_EVENTS_METHODDEF \
+ {"get_events", (PyCFunction)monitoring_get_events, METH_O, monitoring_get_events__doc__},
+
+static int
+monitoring_get_events_impl(PyObject *module, int tool_id);
+
+static PyObject *
+monitoring_get_events(PyObject *module, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ int tool_id;
+ int _return_value;
+
+ tool_id = _PyLong_AsInt(arg);
+ if (tool_id == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ _return_value = monitoring_get_events_impl(module, tool_id);
+ if ((_return_value == -1) && PyErr_Occurred()) {
+ goto exit;
+ }
+ return_value = PyLong_FromLong((long)_return_value);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(monitoring_set_events__doc__,
+"set_events($module, tool_id, event_set, /)\n"
+"--\n"
+"\n");
+
+#define MONITORING_SET_EVENTS_METHODDEF \
+ {"set_events", _PyCFunction_CAST(monitoring_set_events), METH_FASTCALL, monitoring_set_events__doc__},
+
+static PyObject *
+monitoring_set_events_impl(PyObject *module, int tool_id, int event_set);
+
+static PyObject *
+monitoring_set_events(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ int tool_id;
+ int event_set;
+
+ if (!_PyArg_CheckPositional("set_events", nargs, 2, 2)) {
+ goto exit;
+ }
+ tool_id = _PyLong_AsInt(args[0]);
+ if (tool_id == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ event_set = _PyLong_AsInt(args[1]);
+ if (event_set == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ return_value = monitoring_set_events_impl(module, tool_id, event_set);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(monitoring_get_local_events__doc__,
+"get_local_events($module, tool_id, code, /)\n"
+"--\n"
+"\n");
+
+#define MONITORING_GET_LOCAL_EVENTS_METHODDEF \
+ {"get_local_events", _PyCFunction_CAST(monitoring_get_local_events), METH_FASTCALL, monitoring_get_local_events__doc__},
+
+static int
+monitoring_get_local_events_impl(PyObject *module, int tool_id,
+ PyObject *code);
+
+static PyObject *
+monitoring_get_local_events(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ int tool_id;
+ PyObject *code;
+ int _return_value;
+
+ if (!_PyArg_CheckPositional("get_local_events", nargs, 2, 2)) {
+ goto exit;
+ }
+ tool_id = _PyLong_AsInt(args[0]);
+ if (tool_id == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ code = args[1];
+ _return_value = monitoring_get_local_events_impl(module, tool_id, code);
+ if ((_return_value == -1) && PyErr_Occurred()) {
+ goto exit;
+ }
+ return_value = PyLong_FromLong((long)_return_value);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(monitoring_set_local_events__doc__,
+"set_local_events($module, tool_id, code, event_set, /)\n"
+"--\n"
+"\n");
+
+#define MONITORING_SET_LOCAL_EVENTS_METHODDEF \
+ {"set_local_events", _PyCFunction_CAST(monitoring_set_local_events), METH_FASTCALL, monitoring_set_local_events__doc__},
+
+static PyObject *
+monitoring_set_local_events_impl(PyObject *module, int tool_id,
+ PyObject *code, int event_set);
+
+static PyObject *
+monitoring_set_local_events(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ int tool_id;
+ PyObject *code;
+ int event_set;
+
+ if (!_PyArg_CheckPositional("set_local_events", nargs, 3, 3)) {
+ goto exit;
+ }
+ tool_id = _PyLong_AsInt(args[0]);
+ if (tool_id == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ code = args[1];
+ event_set = _PyLong_AsInt(args[2]);
+ if (event_set == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ return_value = monitoring_set_local_events_impl(module, tool_id, code, event_set);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(monitoring_restart_events__doc__,
+"restart_events($module, /)\n"
+"--\n"
+"\n");
+
+#define MONITORING_RESTART_EVENTS_METHODDEF \
+ {"restart_events", (PyCFunction)monitoring_restart_events, METH_NOARGS, monitoring_restart_events__doc__},
+
+static PyObject *
+monitoring_restart_events_impl(PyObject *module);
+
+static PyObject *
+monitoring_restart_events(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return monitoring_restart_events_impl(module);
+}
+
+PyDoc_STRVAR(monitoring__all_events__doc__,
+"_all_events($module, /)\n"
+"--\n"
+"\n");
+
+#define MONITORING__ALL_EVENTS_METHODDEF \
+ {"_all_events", (PyCFunction)monitoring__all_events, METH_NOARGS, monitoring__all_events__doc__},
+
+static PyObject *
+monitoring__all_events_impl(PyObject *module);
+
+static PyObject *
+monitoring__all_events(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return monitoring__all_events_impl(module);
+}
+/*[clinic end generated code: output=11cc0803875b3ffa input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Python/clinic/marshal.c.h b/contrib/tools/python3/src/Python/clinic/marshal.c.h
index 36f2afd524..a593b98054 100644
--- a/contrib/tools/python3/src/Python/clinic/marshal.c.h
+++ b/contrib/tools/python3/src/Python/clinic/marshal.c.h
@@ -2,6 +2,12 @@
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()
+#endif
+
+
PyDoc_STRVAR(marshal_dump__doc__,
"dump($module, value, file, version=version, /)\n"
"--\n"
@@ -155,4 +161,4 @@ exit:
return return_value;
}
-/*[clinic end generated code: output=b9e838edee43fe87 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=12082d61d2942473 input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Python/clinic/sysmodule.c.h b/contrib/tools/python3/src/Python/clinic/sysmodule.c.h
index 8ca3cd0860..7a7c188bcc 100644
--- a/contrib/tools/python3/src/Python/clinic/sysmodule.c.h
+++ b/contrib/tools/python3/src/Python/clinic/sysmodule.c.h
@@ -2,6 +2,12 @@
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()
+#endif
+
+
PyDoc_STRVAR(sys_addaudithook__doc__,
"addaudithook($module, /, hook)\n"
"--\n"
@@ -18,8 +24,31 @@ static PyObject *
sys_addaudithook(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 1
+ 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(hook), },
+ };
+ #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[] = {"hook", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "addaudithook", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "addaudithook",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[1];
PyObject *hook;
@@ -263,6 +292,18 @@ exit:
return return_value;
}
+PyDoc_STRVAR(sys__settraceallthreads__doc__,
+"_settraceallthreads($module, arg, /)\n"
+"--\n"
+"\n"
+"Set the global debug tracing function in all running threads belonging to the current interpreter.\n"
+"\n"
+"It will be called on each function call. See the debugger chapter\n"
+"in the library manual.");
+
+#define SYS__SETTRACEALLTHREADS_METHODDEF \
+ {"_settraceallthreads", (PyCFunction)sys__settraceallthreads, METH_O, sys__settraceallthreads__doc__},
+
PyDoc_STRVAR(sys_gettrace__doc__,
"gettrace($module, /)\n"
"--\n"
@@ -283,6 +324,18 @@ sys_gettrace(PyObject *module, PyObject *Py_UNUSED(ignored))
return sys_gettrace_impl(module);
}
+PyDoc_STRVAR(sys__setprofileallthreads__doc__,
+"_setprofileallthreads($module, arg, /)\n"
+"--\n"
+"\n"
+"Set the profiling function in all running threads belonging to the current interpreter.\n"
+"\n"
+"It will be called on each function call and return. See the profiler chapter\n"
+"in the library manual.");
+
+#define SYS__SETPROFILEALLTHREADS_METHODDEF \
+ {"_setprofileallthreads", (PyCFunction)sys__setprofileallthreads, METH_O, sys__setprofileallthreads__doc__},
+
PyDoc_STRVAR(sys_getprofile__doc__,
"getprofile($module, /)\n"
"--\n"
@@ -425,8 +478,31 @@ static PyObject *
sys_set_coroutine_origin_tracking_depth(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 1
+ 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(depth), },
+ };
+ #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[] = {"depth", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "set_coroutine_origin_tracking_depth", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "set_coroutine_origin_tracking_depth",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[1];
int depth;
@@ -703,8 +779,31 @@ static PyObject *
sys_set_int_max_str_digits(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 1
+ 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(maxdigits), },
+ };
+ #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[] = {"maxdigits", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "set_int_max_str_digits", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "set_int_max_str_digits",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[1];
int maxdigits;
@@ -785,24 +884,25 @@ exit:
#endif /* defined(Py_REF_DEBUG) */
-PyDoc_STRVAR(sys__getquickenedcount__doc__,
-"_getquickenedcount($module, /)\n"
+PyDoc_STRVAR(sys_getallocatedblocks__doc__,
+"getallocatedblocks($module, /)\n"
"--\n"
-"\n");
+"\n"
+"Return the number of memory blocks currently allocated.");
-#define SYS__GETQUICKENEDCOUNT_METHODDEF \
- {"_getquickenedcount", (PyCFunction)sys__getquickenedcount, METH_NOARGS, sys__getquickenedcount__doc__},
+#define SYS_GETALLOCATEDBLOCKS_METHODDEF \
+ {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
static Py_ssize_t
-sys__getquickenedcount_impl(PyObject *module);
+sys_getallocatedblocks_impl(PyObject *module);
static PyObject *
-sys__getquickenedcount(PyObject *module, PyObject *Py_UNUSED(ignored))
+sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
Py_ssize_t _return_value;
- _return_value = sys__getquickenedcount_impl(module);
+ _return_value = sys_getallocatedblocks_impl(module);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
@@ -812,25 +912,25 @@ exit:
return return_value;
}
-PyDoc_STRVAR(sys_getallocatedblocks__doc__,
-"getallocatedblocks($module, /)\n"
+PyDoc_STRVAR(sys_getunicodeinternedsize__doc__,
+"getunicodeinternedsize($module, /)\n"
"--\n"
"\n"
-"Return the number of memory blocks currently allocated.");
+"Return the number of elements of the unicode interned dictionary");
-#define SYS_GETALLOCATEDBLOCKS_METHODDEF \
- {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, sys_getallocatedblocks__doc__},
+#define SYS_GETUNICODEINTERNEDSIZE_METHODDEF \
+ {"getunicodeinternedsize", (PyCFunction)sys_getunicodeinternedsize, METH_NOARGS, sys_getunicodeinternedsize__doc__},
static Py_ssize_t
-sys_getallocatedblocks_impl(PyObject *module);
+sys_getunicodeinternedsize_impl(PyObject *module);
static PyObject *
-sys_getallocatedblocks(PyObject *module, PyObject *Py_UNUSED(ignored))
+sys_getunicodeinternedsize(PyObject *module, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
Py_ssize_t _return_value;
- _return_value = sys_getallocatedblocks_impl(module);
+ _return_value = sys_getunicodeinternedsize_impl(module);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
@@ -1018,6 +1118,94 @@ sys_is_finalizing(PyObject *module, PyObject *Py_UNUSED(ignored))
return sys_is_finalizing_impl(module);
}
+#if defined(Py_STATS)
+
+PyDoc_STRVAR(sys__stats_on__doc__,
+"_stats_on($module, /)\n"
+"--\n"
+"\n"
+"Turns on stats gathering (stats gathering is on by default).");
+
+#define SYS__STATS_ON_METHODDEF \
+ {"_stats_on", (PyCFunction)sys__stats_on, METH_NOARGS, sys__stats_on__doc__},
+
+static PyObject *
+sys__stats_on_impl(PyObject *module);
+
+static PyObject *
+sys__stats_on(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return sys__stats_on_impl(module);
+}
+
+#endif /* defined(Py_STATS) */
+
+#if defined(Py_STATS)
+
+PyDoc_STRVAR(sys__stats_off__doc__,
+"_stats_off($module, /)\n"
+"--\n"
+"\n"
+"Turns off stats gathering (stats gathering is on by default).");
+
+#define SYS__STATS_OFF_METHODDEF \
+ {"_stats_off", (PyCFunction)sys__stats_off, METH_NOARGS, sys__stats_off__doc__},
+
+static PyObject *
+sys__stats_off_impl(PyObject *module);
+
+static PyObject *
+sys__stats_off(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return sys__stats_off_impl(module);
+}
+
+#endif /* defined(Py_STATS) */
+
+#if defined(Py_STATS)
+
+PyDoc_STRVAR(sys__stats_clear__doc__,
+"_stats_clear($module, /)\n"
+"--\n"
+"\n"
+"Clears the stats.");
+
+#define SYS__STATS_CLEAR_METHODDEF \
+ {"_stats_clear", (PyCFunction)sys__stats_clear, METH_NOARGS, sys__stats_clear__doc__},
+
+static PyObject *
+sys__stats_clear_impl(PyObject *module);
+
+static PyObject *
+sys__stats_clear(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return sys__stats_clear_impl(module);
+}
+
+#endif /* defined(Py_STATS) */
+
+#if defined(Py_STATS)
+
+PyDoc_STRVAR(sys__stats_dump__doc__,
+"_stats_dump($module, /)\n"
+"--\n"
+"\n"
+"Dump stats to file, and clears the stats.");
+
+#define SYS__STATS_DUMP_METHODDEF \
+ {"_stats_dump", (PyCFunction)sys__stats_dump, METH_NOARGS, sys__stats_dump__doc__},
+
+static PyObject *
+sys__stats_dump_impl(PyObject *module);
+
+static PyObject *
+sys__stats_dump(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return sys__stats_dump_impl(module);
+}
+
+#endif /* defined(Py_STATS) */
+
#if defined(ANDROID_API_LEVEL)
PyDoc_STRVAR(sys_getandroidapilevel__doc__,
@@ -1040,6 +1228,150 @@ sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
#endif /* defined(ANDROID_API_LEVEL) */
+PyDoc_STRVAR(sys_activate_stack_trampoline__doc__,
+"activate_stack_trampoline($module, backend, /)\n"
+"--\n"
+"\n"
+"Activate stack profiler trampoline *backend*.");
+
+#define SYS_ACTIVATE_STACK_TRAMPOLINE_METHODDEF \
+ {"activate_stack_trampoline", (PyCFunction)sys_activate_stack_trampoline, METH_O, sys_activate_stack_trampoline__doc__},
+
+static PyObject *
+sys_activate_stack_trampoline_impl(PyObject *module, const char *backend);
+
+static PyObject *
+sys_activate_stack_trampoline(PyObject *module, PyObject *arg)
+{
+ PyObject *return_value = NULL;
+ const char *backend;
+
+ if (!PyUnicode_Check(arg)) {
+ _PyArg_BadArgument("activate_stack_trampoline", "argument", "str", arg);
+ goto exit;
+ }
+ Py_ssize_t backend_length;
+ backend = PyUnicode_AsUTF8AndSize(arg, &backend_length);
+ if (backend == NULL) {
+ goto exit;
+ }
+ if (strlen(backend) != (size_t)backend_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ return_value = sys_activate_stack_trampoline_impl(module, backend);
+
+exit:
+ return return_value;
+}
+
+PyDoc_STRVAR(sys_deactivate_stack_trampoline__doc__,
+"deactivate_stack_trampoline($module, /)\n"
+"--\n"
+"\n"
+"Deactivate the current stack profiler trampoline backend.\n"
+"\n"
+"If no stack profiler is activated, this function has no effect.");
+
+#define SYS_DEACTIVATE_STACK_TRAMPOLINE_METHODDEF \
+ {"deactivate_stack_trampoline", (PyCFunction)sys_deactivate_stack_trampoline, METH_NOARGS, sys_deactivate_stack_trampoline__doc__},
+
+static PyObject *
+sys_deactivate_stack_trampoline_impl(PyObject *module);
+
+static PyObject *
+sys_deactivate_stack_trampoline(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return sys_deactivate_stack_trampoline_impl(module);
+}
+
+PyDoc_STRVAR(sys_is_stack_trampoline_active__doc__,
+"is_stack_trampoline_active($module, /)\n"
+"--\n"
+"\n"
+"Return *True* if a stack profiler trampoline is active.");
+
+#define SYS_IS_STACK_TRAMPOLINE_ACTIVE_METHODDEF \
+ {"is_stack_trampoline_active", (PyCFunction)sys_is_stack_trampoline_active, METH_NOARGS, sys_is_stack_trampoline_active__doc__},
+
+static PyObject *
+sys_is_stack_trampoline_active_impl(PyObject *module);
+
+static PyObject *
+sys_is_stack_trampoline_active(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return sys_is_stack_trampoline_active_impl(module);
+}
+
+PyDoc_STRVAR(sys__getframemodulename__doc__,
+"_getframemodulename($module, /, depth=0)\n"
+"--\n"
+"\n"
+"Return the name of the module for a calling frame.\n"
+"\n"
+"The default depth returns the module containing the call to this API.\n"
+"A more typical use in a library will pass a depth of 1 to get the user\'s\n"
+"module rather than the library module.\n"
+"\n"
+"If no frame, module, or name can be found, returns None.");
+
+#define SYS__GETFRAMEMODULENAME_METHODDEF \
+ {"_getframemodulename", _PyCFunction_CAST(sys__getframemodulename), METH_FASTCALL|METH_KEYWORDS, sys__getframemodulename__doc__},
+
+static PyObject *
+sys__getframemodulename_impl(PyObject *module, int depth);
+
+static PyObject *
+sys__getframemodulename(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 1
+ 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(depth), },
+ };
+ #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[] = {"depth", NULL};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "_getframemodulename",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
+ PyObject *argsbuf[1];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
+ int depth = 0;
+
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ depth = _PyLong_AsInt(args[0]);
+ if (depth == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+skip_optional_pos:
+ return_value = sys__getframemodulename_impl(module, depth);
+
+exit:
+ return return_value;
+}
+
#ifndef SYS_GETWINDOWSVERSION_METHODDEF
#define SYS_GETWINDOWSVERSION_METHODDEF
#endif /* !defined(SYS_GETWINDOWSVERSION_METHODDEF) */
@@ -1064,7 +1396,23 @@ sys_getandroidapilevel(PyObject *module, PyObject *Py_UNUSED(ignored))
#define SYS_GETTOTALREFCOUNT_METHODDEF
#endif /* !defined(SYS_GETTOTALREFCOUNT_METHODDEF) */
+#ifndef SYS__STATS_ON_METHODDEF
+ #define SYS__STATS_ON_METHODDEF
+#endif /* !defined(SYS__STATS_ON_METHODDEF) */
+
+#ifndef SYS__STATS_OFF_METHODDEF
+ #define SYS__STATS_OFF_METHODDEF
+#endif /* !defined(SYS__STATS_OFF_METHODDEF) */
+
+#ifndef SYS__STATS_CLEAR_METHODDEF
+ #define SYS__STATS_CLEAR_METHODDEF
+#endif /* !defined(SYS__STATS_CLEAR_METHODDEF) */
+
+#ifndef SYS__STATS_DUMP_METHODDEF
+ #define SYS__STATS_DUMP_METHODDEF
+#endif /* !defined(SYS__STATS_DUMP_METHODDEF) */
+
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
#define SYS_GETANDROIDAPILEVEL_METHODDEF
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
-/*[clinic end generated code: output=3cae0e0212d88bcd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6d598acc26237fbe input=a9049054013a1b77]*/
diff --git a/contrib/tools/python3/src/Python/clinic/traceback.c.h b/contrib/tools/python3/src/Python/clinic/traceback.c.h
index 404a0c416d..3c34493497 100644
--- a/contrib/tools/python3/src/Python/clinic/traceback.c.h
+++ b/contrib/tools/python3/src/Python/clinic/traceback.c.h
@@ -2,6 +2,12 @@
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()
+#endif
+
+
PyDoc_STRVAR(tb_new__doc__,
"TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)\n"
"--\n"
@@ -16,8 +22,31 @@ static PyObject *
tb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
+ #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
+
+ #define NUM_KEYWORDS 4
+ 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(tb_next), &_Py_ID(tb_frame), &_Py_ID(tb_lasti), &_Py_ID(tb_lineno), },
+ };
+ #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[] = {"tb_next", "tb_frame", "tb_lasti", "tb_lineno", NULL};
- static _PyArg_Parser _parser = {NULL, _keywords, "TracebackType", 0};
+ static _PyArg_Parser _parser = {
+ .keywords = _keywords,
+ .fname = "TracebackType",
+ .kwtuple = KWTUPLE,
+ };
+ #undef KWTUPLE
PyObject *argsbuf[4];
PyObject * const *fastargs;
Py_ssize_t nargs = PyTuple_GET_SIZE(args);
@@ -49,4 +78,4 @@ tb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
exit:
return return_value;
}
-/*[clinic end generated code: output=403778d7af5ebef9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7bc9927e362fdfb7 input=a9049054013a1b77]*/