Backporting METH_FASTCALL from Python 3.7 (#317)

* dict copy speedup

refer to bpo-31179 or python/cpython@boa7a037b8fde

* __build_class__() uses METH_FASTCALL

refer python/cpython@69de71b255
refer python/cpython@773dc6dd06

a single test related to __prepare__ fails.

* type_prepare uses METH_FASTCALL

refer python/cpython@d526cfe546
refer python/cpython@80ab22fa2c

the prepare-related test still fails.  It's just related to the error
message format though.

* separate into ParseStack and ParseStackAndKeywords

refer python/cpython@6518a93cb1
refer python/cpython@3e1fad6913
refer python/cpython@c0083fc47d

* Add _PyArg_NoStackKeywords

refer python/cpython@29d39cc8f5

* _PyStack_UnpackDict now returns int

refer python/cpython@998c20962c

* METH_FASTCALL changes to .inc files

done via python's Argument Clinic tool,
refer python/cpython@259f0e4437

* Added _PyArg_UnpackStack

refer python/cpython@fe54dda08

* Argument Clinic FASTCALL again

refer python/cpython@0c4a828ca

* Argument Clinic for ordered dictionary object

refer python/cpython@b05cbac052

* speed up getargs

refer python/cpython@1741441649

* FASTCALL for sorted, next, and getattr

refer python/cpython@5a60ecaa7a
refer python/cpython@fda6d0acf0
refer python/cpython@84b388bb80

* Optimize methoddescr_call

refer python/cpython@2a1b676d1f
refer python/cpython@c52572319c
refer python/cpython@35ecebe165
refer python/cpython@8128d5a491

* cleanup _PyMethodDef_RawFastCallDict

refer python/cpython@0a2e46835d
refer python/cpython@98ccba8344
refer python/cpython@c89ef828cf
refer python/cpython@250e4b0063

* print now uses METH_FASTCALL

refer python/cpython@c3858bd7c6
refer python/cpython@bd584f169f
refer python/cpython@06d34393c2

* _struct module now uses Argument Clinic

refer python/cpython@3f2d10132d

* make deque methods faster

refer python/cpython@dd407d5006

* recursive calls in PyObject_Call

refer python/cpython@7399a05965

only partially ported, because RawFastCallKeywords hasn't been ported

* add macros

refer python/cpython@68a001dd59

* all tests pass in MODE=dbg

* convert some internal functions to FASTCALL

__import__ might need to be changed later, if it is possible to backport
the METH_FASTCALL | METH_KEYWORDS flag distinction later.

* speed up unpickling

refer python/cpython@bee09aecc2

* added _PyMethodDef_RawFastCallKeywords

refer python/cpython@7399a05965

* PyCFunction_Call performance

refer python/cpython@12c5838dae

* avoid PyMethodObject in slots

main change in python/cpython@516b98161a
test_exceptions changed in python/cpython@331bbe6aaa
type_settattro changed in python/cpython@193f7e094f
_PyObject_CallFunctionVa changed in python/cpython@fe4ff83049

* fix refcount error found in MODE=dbg

all tests now pass in MODE=dbg
This commit is contained in:
Gautham 2021-11-13 04:56:57 +05:30 committed by GitHub
parent 6f658f058b
commit 7fe9e70117
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 4154 additions and 2450 deletions

View file

@ -239,51 +239,45 @@ _Py_IDENTIFIER(stderr);
/* AC: cannot convert yet, waiting for *args support */
static PyObject *
builtin___build_class__(PyObject *self, PyObject *args, PyObject *kwds)
builtin___build_class__(PyObject *self, PyObject **args, Py_ssize_t nargs,
PyObject *kwnames)
{
PyObject *func, *name, *bases, *mkw, *meta, *winner, *prep, *ns;
PyObject *cls = NULL, *cell = NULL;
Py_ssize_t nargs;
int isclass = 0; /* initialize to prevent gcc warning */
assert(args != NULL);
if (!PyTuple_Check(args)) {
PyErr_SetString(PyExc_TypeError,
"__build_class__: args is not a tuple");
return NULL;
}
nargs = PyTuple_GET_SIZE(args);
if (nargs < 2) {
PyErr_SetString(PyExc_TypeError,
"__build_class__: not enough arguments");
return NULL;
}
func = PyTuple_GET_ITEM(args, 0); /* Better be callable */
func = args[0]; /* Better be callable */
if (!PyFunction_Check(func)) {
PyErr_SetString(PyExc_TypeError,
"__build_class__: func must be a function");
return NULL;
}
name = PyTuple_GET_ITEM(args, 1);
name = args[1];
if (!PyUnicode_Check(name)) {
PyErr_SetString(PyExc_TypeError,
"__build_class__: name is not a string");
return NULL;
}
bases = PyTuple_GetSlice(args, 2, nargs);
bases = _PyStack_AsTupleSlice(args, nargs, 2, nargs);
if (bases == NULL)
return NULL;
if (kwds == NULL) {
if (kwnames == NULL) {
meta = NULL;
mkw = NULL;
}
else {
mkw = PyDict_Copy(kwds); /* Don't modify kwds passed in! */
mkw = _PyStack_AsDict(args + nargs, kwnames);
if (mkw == NULL) {
Py_DECREF(bases);
return NULL;
}
meta = _PyDict_GetItemId(mkw, &PyId_metaclass);
if (meta != NULL) {
Py_INCREF(meta);
@ -412,15 +406,16 @@ PyDoc_STRVAR(build_class_doc,
Internal helper function used by the class statement.");
static PyObject *
builtin___import__(PyObject *self, PyObject *args, PyObject *kwds)
builtin___import__(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwds)
{
static char *kwlist[] = {"name", "globals", "locals", "fromlist",
static const char * const kwlist[] = {"name", "globals", "locals", "fromlist",
"level", 0};
PyObject *name, *globals = NULL, *locals = NULL, *fromlist = NULL;
int level = 0;
static _PyArg_Parser _parser = {"U|OOOi:__import__", kwlist, 0};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "U|OOOi:__import__",
kwlist, &name, &globals, &locals, &fromlist, &level))
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwds, &_parser,
&name, &globals, &locals, &fromlist, &level))
return NULL;
return PyImport_ImportModuleLevelObject(name, globals, locals,
fromlist, level);
@ -979,11 +974,13 @@ finally:
/* AC: cannot convert yet, as needs PEP 457 group support in inspect */
static PyObject *
builtin_dir(PyObject *self, PyObject *args)
builtin_dir(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *arg = NULL;
if (!PyArg_UnpackTuple(args, "dir", 0, 1, &arg))
if (!_PyArg_UnpackStack(args, nargs, "dir", 0, 1, &arg))
return NULL;
if (!_PyArg_NoStackKeywords("dir", kwnames))
return NULL;
return PyObject_Dir(arg);
}
@ -1195,14 +1192,19 @@ builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals,
/* AC: cannot convert yet, as needs PEP 457 group support in inspect */
static PyObject *
builtin_getattr(PyObject *self, PyObject *args)
builtin_getattr(PyObject *self, PyObject **args, Py_ssize_t nargs,
PyObject *kwnames)
{
PyObject *v, *result, *dflt = NULL;
PyObject *name;
if (!PyArg_UnpackTuple(args, "getattr", 2, 3, &v, &name, &dflt))
if (!_PyArg_UnpackStack(args, nargs, "getattr", 2, 3, &v, &name, &dflt))
return NULL;
if (!_PyArg_NoStackKeywords("getattr", kwnames)) {
return NULL;
}
if (!PyUnicode_Check(name)) {
PyErr_SetString(PyExc_TypeError,
"getattr(): attribute name must be string");
@ -1500,13 +1502,19 @@ PyTypeObject PyMap_Type = {
/* AC: cannot convert yet, as needs PEP 457 group support in inspect */
static PyObject *
builtin_next(PyObject *self, PyObject *args)
builtin_next(PyObject *self, PyObject **args, Py_ssize_t nargs,
PyObject *kwnames)
{
PyObject *it, *res;
PyObject *def = NULL;
if (!PyArg_UnpackTuple(args, "next", 1, 2, &it, &def))
if (!_PyArg_UnpackStack(args, nargs, "next", 1, 2, &it, &def))
return NULL;
if (!_PyArg_NoStackKeywords("next", kwnames)) {
return NULL;
}
if (!PyIter_Check(it)) {
PyErr_Format(PyExc_TypeError,
"'%.200s' object is not an iterator",
@ -1635,11 +1643,13 @@ builtin_hex(PyObject *module, PyObject *number)
/* AC: cannot convert yet, as needs PEP 457 group support in inspect */
static PyObject *
builtin_iter(PyObject *self, PyObject *args)
builtin_iter(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *v, *w = NULL;
if (!PyArg_UnpackTuple(args, "iter", 1, 2, &v, &w))
if (!_PyArg_UnpackStack(args, nargs, "iter", 1, 2, &v, &w))
return NULL;
if(!_PyArg_NoStackKeywords("iter", kwnames))
return NULL;
if (w == NULL)
return PyObject_GetIter(v);
@ -1938,18 +1948,19 @@ builtin_pow_impl(PyObject *module, PyObject *x, PyObject *y, PyObject *z)
/* AC: cannot convert yet, waiting for *args support */
static PyObject *
builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
builtin_print(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
static char *kwlist[] = {"sep", "end", "file", "flush", 0};
static PyObject *dummy_args;
static const char * const _keywords[] = {"sep", "end", "file", "flush", 0};
static struct _PyArg_Parser _parser = {"|OOOO:print", _keywords, 0};
PyObject *sep = NULL, *end = NULL, *file = NULL, *flush = NULL;
int i, err;
if (dummy_args == NULL && !(dummy_args = PyTuple_New(0)))
return NULL;
if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOOO:print",
kwlist, &sep, &end, &file, &flush))
if (kwnames != NULL &&
!_PyArg_ParseStackAndKeywords(args + nargs, 0, kwnames, &_parser,
&sep, &end, &file, &flush)) {
return NULL;
}
if (file == NULL || file == Py_None) {
file = _PySys_GetObjectId(&PyId_stdout);
if (file == NULL) {
@ -1981,7 +1992,7 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
return NULL;
}
for (i = 0; i < PyTuple_Size(args); i++) {
for (i = 0; i < nargs; i++) {
if (i > 0) {
if (sep == NULL)
err = PyFile_WriteString(" ", file);
@ -1991,8 +2002,7 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
if (err)
return NULL;
}
err = PyFile_WriteObject(PyTuple_GetItem(args, i), file,
Py_PRINT_RAW);
err = PyFile_WriteObject(args[i], file, Py_PRINT_RAW);
if (err)
return NULL;
}
@ -2323,20 +2333,20 @@ PyDoc_STRVAR(builtin_sorted__doc__,
"reverse flag can be set to request the result in descending order.");
#define BUILTIN_SORTED_METHODDEF \
{"sorted", (PyCFunction)builtin_sorted, METH_VARARGS|METH_KEYWORDS, builtin_sorted__doc__},
{"sorted", (PyCFunction)builtin_sorted, METH_FASTCALL, builtin_sorted__doc__},
static PyObject *
builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds)
builtin_sorted(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *newlist, *v, *seq, *keyfunc=NULL, **newargs;
PyObject *newlist, *v, *seq, *keyfunc=NULL;
PyObject *callable;
static char *kwlist[] = {"", "key", "reverse", 0};
int reverse;
Py_ssize_t nargs;
static const char * const kwlist[] = {"", "key", "reverse", 0};
/* args 1-3 should match listsort in Objects/listobject.c */
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oi:sorted",
kwlist, &seq, &keyfunc, &reverse))
static _PyArg_Parser parser = {"O|Oi:sorted", kwlist, 0};
int reverse;
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &parser,
&seq, &keyfunc, &reverse))
return NULL;
newlist = PySequence_List(seq);
@ -2349,10 +2359,7 @@ builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds)
return NULL;
}
assert(PyTuple_GET_SIZE(args) >= 1);
newargs = &PyTuple_GET_ITEM(args, 1);
nargs = PyTuple_GET_SIZE(args) - 1;
v = _PyObject_FastCallDict(callable, newargs, nargs, kwds);
v = _PyObject_FastCallKeywords(callable, args + 1, nargs - 1, kwnames);
Py_DECREF(callable);
if (v == NULL) {
Py_DECREF(newlist);
@ -2365,12 +2372,14 @@ builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds)
/* AC: cannot convert yet, as needs PEP 457 group support in inspect */
static PyObject *
builtin_vars(PyObject *self, PyObject *args)
builtin_vars(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *v = NULL;
PyObject *d;
if (!PyArg_UnpackTuple(args, "vars", 0, 1, &v))
if (!_PyArg_UnpackStack(args, nargs, "vars", 0, 1, &v))
return NULL;
if(!_PyArg_NoStackKeywords("vars", kwnames))
return NULL;
if (v == NULL) {
d = PyEval_GetLocals();
@ -2825,8 +2834,8 @@ PyTypeObject PyZip_Type = {
static PyMethodDef builtin_methods[] = {
{"__build_class__", (PyCFunction)builtin___build_class__,
METH_VARARGS | METH_KEYWORDS, build_class_doc},
{"__import__", (PyCFunction)builtin___import__, METH_VARARGS | METH_KEYWORDS, import_doc},
METH_FASTCALL, build_class_doc},
{"__import__", (PyCFunction)builtin___import__, METH_FASTCALL, import_doc},
BUILTIN_ABS_METHODDEF
BUILTIN_ALL_METHODDEF
BUILTIN_ANY_METHODDEF
@ -2836,12 +2845,12 @@ static PyMethodDef builtin_methods[] = {
BUILTIN_CHR_METHODDEF
BUILTIN_COMPILE_METHODDEF
BUILTIN_DELATTR_METHODDEF
{"dir", builtin_dir, METH_VARARGS, dir_doc},
{"dir", (PyCFunction)builtin_dir, METH_FASTCALL, dir_doc},
BUILTIN_DIVMOD_METHODDEF
BUILTIN_EVAL_METHODDEF
BUILTIN_EXEC_METHODDEF
BUILTIN_FORMAT_METHODDEF
{"getattr", builtin_getattr, METH_VARARGS, getattr_doc},
{"getattr", (PyCFunction)builtin_getattr, METH_FASTCALL, getattr_doc},
BUILTIN_GLOBALS_METHODDEF
BUILTIN_HASATTR_METHODDEF
BUILTIN_HASH_METHODDEF
@ -2850,22 +2859,22 @@ static PyMethodDef builtin_methods[] = {
BUILTIN_INPUT_METHODDEF
BUILTIN_ISINSTANCE_METHODDEF
BUILTIN_ISSUBCLASS_METHODDEF
{"iter", builtin_iter, METH_VARARGS, iter_doc},
{"iter", (PyCFunction)builtin_iter, METH_FASTCALL, iter_doc},
BUILTIN_LEN_METHODDEF
BUILTIN_LOCALS_METHODDEF
{"max", (PyCFunction)builtin_max, METH_VARARGS | METH_KEYWORDS, max_doc},
{"min", (PyCFunction)builtin_min, METH_VARARGS | METH_KEYWORDS, min_doc},
{"next", (PyCFunction)builtin_next, METH_VARARGS, next_doc},
{"next", (PyCFunction)builtin_next, METH_FASTCALL, next_doc},
BUILTIN_OCT_METHODDEF
BUILTIN_ORD_METHODDEF
BUILTIN_POW_METHODDEF
{"print", (PyCFunction)builtin_print, METH_VARARGS | METH_KEYWORDS, print_doc},
{"print", (PyCFunction)builtin_print, METH_FASTCALL, print_doc},
BUILTIN_REPR_METHODDEF
{"round", (PyCFunction)builtin_round, METH_VARARGS | METH_KEYWORDS, round_doc},
BUILTIN_SETATTR_METHODDEF
BUILTIN_SORTED_METHODDEF
BUILTIN_SUM_METHODDEF
{"vars", builtin_vars, METH_VARARGS, vars_doc},
{"vars", (PyCFunction)builtin_vars, METH_FASTCALL, vars_doc},
{NULL, NULL},
};

View file

@ -1,11 +1,4 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
╞══════════════════════════════════════════════════════════════════════════════╡
Python 3
https://docs.python.org/3/license.html
╚─────────────────────────────────────────────────────────────────────────────*/
/* clang-format off */
/*[clinic input]
preserve
[clinic start generated code]*/
@ -90,22 +83,26 @@ PyDoc_STRVAR(builtin_format__doc__,
"details.");
#define BUILTIN_FORMAT_METHODDEF \
{"format", (PyCFunction)builtin_format, METH_VARARGS, builtin_format__doc__},
{"format", (PyCFunction)builtin_format, METH_FASTCALL, builtin_format__doc__},
static PyObject *
builtin_format_impl(PyObject *module, PyObject *value, PyObject *format_spec);
static PyObject *
builtin_format(PyObject *module, PyObject *args)
builtin_format(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *value;
PyObject *format_spec = NULL;
if (!PyArg_ParseTuple(args, "O|U:format",
if (!_PyArg_ParseStack(args, nargs, "O|U:format",
&value, &format_spec)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("format", kwnames)) {
goto exit;
}
return_value = builtin_format_impl(module, value, format_spec);
exit:
@ -127,9 +124,16 @@ builtin_chr_impl(PyObject *module, int i);
static PyObject *
builtin_chr(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
int i;
if (!PyArg_Parse(arg, "i:chr", &i)) return 0;
return builtin_chr_impl(module, i);
if (!PyArg_Parse(arg, "i:chr", &i)) {
goto exit;
}
return_value = builtin_chr_impl(module, i);
exit:
return return_value;
}
PyDoc_STRVAR(builtin_compile__doc__,
@ -171,7 +175,7 @@ builtin_compile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *k
int dont_inherit = 0;
int optimize = -1;
if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
&source, PyUnicode_FSDecoder, &filename, &mode, &flags, &dont_inherit, &optimize)) {
goto exit;
}
@ -188,23 +192,27 @@ PyDoc_STRVAR(builtin_divmod__doc__,
"Return the tuple (x//y, x%y). Invariant: div*y + mod == x.");
#define BUILTIN_DIVMOD_METHODDEF \
{"divmod", (PyCFunction)builtin_divmod, METH_VARARGS, builtin_divmod__doc__},
{"divmod", (PyCFunction)builtin_divmod, METH_FASTCALL, builtin_divmod__doc__},
static PyObject *
builtin_divmod_impl(PyObject *module, PyObject *x, PyObject *y);
static PyObject *
builtin_divmod(PyObject *module, PyObject *args)
builtin_divmod(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *x;
PyObject *y;
if (!PyArg_UnpackTuple(args, "divmod",
if (!_PyArg_UnpackStack(args, nargs, "divmod",
2, 2,
&x, &y)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("divmod", kwnames)) {
goto exit;
}
return_value = builtin_divmod_impl(module, x, y);
exit:
@ -224,25 +232,29 @@ PyDoc_STRVAR(builtin_eval__doc__,
"If only globals is given, locals defaults to it.");
#define BUILTIN_EVAL_METHODDEF \
{"eval", (PyCFunction)builtin_eval, METH_VARARGS, builtin_eval__doc__},
{"eval", (PyCFunction)builtin_eval, METH_FASTCALL, builtin_eval__doc__},
static PyObject *
builtin_eval_impl(PyObject *module, PyObject *source, PyObject *globals,
PyObject *locals);
static PyObject *
builtin_eval(PyObject *module, PyObject *args)
builtin_eval(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *source;
PyObject *globals = Py_None;
PyObject *locals = Py_None;
if (!PyArg_UnpackTuple(args, "eval",
if (!_PyArg_UnpackStack(args, nargs, "eval",
1, 3,
&source, &globals, &locals)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("eval", kwnames)) {
goto exit;
}
return_value = builtin_eval_impl(module, source, globals, locals);
exit:
@ -262,25 +274,29 @@ PyDoc_STRVAR(builtin_exec__doc__,
"If only globals is given, locals defaults to it.");
#define BUILTIN_EXEC_METHODDEF \
{"exec", (PyCFunction)builtin_exec, METH_VARARGS, builtin_exec__doc__},
{"exec", (PyCFunction)builtin_exec, METH_FASTCALL, builtin_exec__doc__},
static PyObject *
builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals,
PyObject *locals);
static PyObject *
builtin_exec(PyObject *module, PyObject *args)
builtin_exec(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *source;
PyObject *globals = Py_None;
PyObject *locals = Py_None;
if (!PyArg_UnpackTuple(args, "exec",
if (!_PyArg_UnpackStack(args, nargs, "exec",
1, 3,
&source, &globals, &locals)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("exec", kwnames)) {
goto exit;
}
return_value = builtin_exec_impl(module, source, globals, locals);
exit:
@ -317,23 +333,27 @@ PyDoc_STRVAR(builtin_hasattr__doc__,
"This is done by calling getattr(obj, name) and catching AttributeError.");
#define BUILTIN_HASATTR_METHODDEF \
{"hasattr", (PyCFunction)builtin_hasattr, METH_VARARGS, builtin_hasattr__doc__},
{"hasattr", (PyCFunction)builtin_hasattr, METH_FASTCALL, builtin_hasattr__doc__},
static PyObject *
builtin_hasattr_impl(PyObject *module, PyObject *obj, PyObject *name);
static PyObject *
builtin_hasattr(PyObject *module, PyObject *args)
builtin_hasattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *obj;
PyObject *name;
if (!PyArg_UnpackTuple(args, "hasattr",
if (!_PyArg_UnpackStack(args, nargs, "hasattr",
2, 2,
&obj, &name)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("hasattr", kwnames)) {
goto exit;
}
return_value = builtin_hasattr_impl(module, obj, name);
exit:
@ -361,25 +381,29 @@ PyDoc_STRVAR(builtin_setattr__doc__,
"setattr(x, \'y\', v) is equivalent to ``x.y = v\'\'");
#define BUILTIN_SETATTR_METHODDEF \
{"setattr", (PyCFunction)builtin_setattr, METH_VARARGS, builtin_setattr__doc__},
{"setattr", (PyCFunction)builtin_setattr, METH_FASTCALL, builtin_setattr__doc__},
static PyObject *
builtin_setattr_impl(PyObject *module, PyObject *obj, PyObject *name,
PyObject *value);
static PyObject *
builtin_setattr(PyObject *module, PyObject *args)
builtin_setattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *obj;
PyObject *name;
PyObject *value;
if (!PyArg_UnpackTuple(args, "setattr",
if (!_PyArg_UnpackStack(args, nargs, "setattr",
3, 3,
&obj, &name, &value)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("setattr", kwnames)) {
goto exit;
}
return_value = builtin_setattr_impl(module, obj, name, value);
exit:
@ -395,23 +419,27 @@ PyDoc_STRVAR(builtin_delattr__doc__,
"delattr(x, \'y\') is equivalent to ``del x.y\'\'");
#define BUILTIN_DELATTR_METHODDEF \
{"delattr", (PyCFunction)builtin_delattr, METH_VARARGS, builtin_delattr__doc__},
{"delattr", (PyCFunction)builtin_delattr, METH_FASTCALL, builtin_delattr__doc__},
static PyObject *
builtin_delattr_impl(PyObject *module, PyObject *obj, PyObject *name);
static PyObject *
builtin_delattr(PyObject *module, PyObject *args)
builtin_delattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *obj;
PyObject *name;
if (!PyArg_UnpackTuple(args, "delattr",
if (!_PyArg_UnpackStack(args, nargs, "delattr",
2, 2,
&obj, &name)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("delattr", kwnames)) {
goto exit;
}
return_value = builtin_delattr_impl(module, obj, name);
exit:
@ -504,24 +532,28 @@ PyDoc_STRVAR(builtin_pow__doc__,
"invoked using the three argument form.");
#define BUILTIN_POW_METHODDEF \
{"pow", (PyCFunction)builtin_pow, METH_VARARGS, builtin_pow__doc__},
{"pow", (PyCFunction)builtin_pow, METH_FASTCALL, builtin_pow__doc__},
static PyObject *
builtin_pow_impl(PyObject *module, PyObject *x, PyObject *y, PyObject *z);
static PyObject *
builtin_pow(PyObject *module, PyObject *args)
builtin_pow(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *x;
PyObject *y;
PyObject *z = Py_None;
if (!PyArg_UnpackTuple(args, "pow",
if (!_PyArg_UnpackStack(args, nargs, "pow",
2, 3,
&x, &y, &z)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("pow", kwnames)) {
goto exit;
}
return_value = builtin_pow_impl(module, x, y, z);
exit:
@ -541,22 +573,26 @@ PyDoc_STRVAR(builtin_input__doc__,
"On *nix systems, readline is used if available.");
#define BUILTIN_INPUT_METHODDEF \
{"input", (PyCFunction)builtin_input, METH_VARARGS, builtin_input__doc__},
{"input", (PyCFunction)builtin_input, METH_FASTCALL, builtin_input__doc__},
static PyObject *
builtin_input_impl(PyObject *module, PyObject *prompt);
static PyObject *
builtin_input(PyObject *module, PyObject *args)
builtin_input(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *prompt = NULL;
if (!PyArg_UnpackTuple(args, "input",
if (!_PyArg_UnpackStack(args, nargs, "input",
0, 1,
&prompt)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("input", kwnames)) {
goto exit;
}
return_value = builtin_input_impl(module, prompt);
exit:
@ -585,23 +621,27 @@ PyDoc_STRVAR(builtin_sum__doc__,
"reject non-numeric types.");
#define BUILTIN_SUM_METHODDEF \
{"sum", (PyCFunction)builtin_sum, METH_VARARGS, builtin_sum__doc__},
{"sum", (PyCFunction)builtin_sum, METH_FASTCALL, builtin_sum__doc__},
static PyObject *
builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start);
static PyObject *
builtin_sum(PyObject *module, PyObject *args)
builtin_sum(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *iterable;
PyObject *start = NULL;
if (!PyArg_UnpackTuple(args, "sum",
if (!_PyArg_UnpackStack(args, nargs, "sum",
1, 2,
&iterable, &start)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("sum", kwnames)) {
goto exit;
}
return_value = builtin_sum_impl(module, iterable, start);
exit:
@ -619,24 +659,28 @@ PyDoc_STRVAR(builtin_isinstance__doc__,
"or ...`` etc.");
#define BUILTIN_ISINSTANCE_METHODDEF \
{"isinstance", (PyCFunction)builtin_isinstance, METH_VARARGS, builtin_isinstance__doc__},
{"isinstance", (PyCFunction)builtin_isinstance, METH_FASTCALL, builtin_isinstance__doc__},
static PyObject *
builtin_isinstance_impl(PyObject *module, PyObject *obj,
PyObject *class_or_tuple);
static PyObject *
builtin_isinstance(PyObject *module, PyObject *args)
builtin_isinstance(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *obj;
PyObject *class_or_tuple;
if (!PyArg_UnpackTuple(args, "isinstance",
if (!_PyArg_UnpackStack(args, nargs, "isinstance",
2, 2,
&obj, &class_or_tuple)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("isinstance", kwnames)) {
goto exit;
}
return_value = builtin_isinstance_impl(module, obj, class_or_tuple);
exit:
@ -654,27 +698,31 @@ PyDoc_STRVAR(builtin_issubclass__doc__,
"or ...`` etc.");
#define BUILTIN_ISSUBCLASS_METHODDEF \
{"issubclass", (PyCFunction)builtin_issubclass, METH_VARARGS, builtin_issubclass__doc__},
{"issubclass", (PyCFunction)builtin_issubclass, METH_FASTCALL, builtin_issubclass__doc__},
static PyObject *
builtin_issubclass_impl(PyObject *module, PyObject *cls,
PyObject *class_or_tuple);
static PyObject *
builtin_issubclass(PyObject *module, PyObject *args)
builtin_issubclass(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *cls;
PyObject *class_or_tuple;
if (!PyArg_UnpackTuple(args, "issubclass",
if (!_PyArg_UnpackStack(args, nargs, "issubclass",
2, 2,
&cls, &class_or_tuple)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("issubclass", kwnames)) {
goto exit;
}
return_value = builtin_issubclass_impl(module, cls, class_or_tuple);
exit:
return return_value;
}
/*[clinic end generated code: output=2ef82846acdfa0f5 input=a9049054013a1b77]*/
/*[clinic end generated code: output=17fedd2dec148677 input=a9049054013a1b77]*/

View file

@ -1,348 +1,373 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:4;tab-width:8;coding:utf-8 -*-
│vi: set net ft=c ts=4 sts=4 sw=4 fenc=utf-8 :vi│
╞══════════════════════════════════════════════════════════════════════════════╡
Python 3
https://docs.python.org/3/license.html
╚─────────────────────────────────────────────────────────────────────────────*/
#include "third_party/python/Include/pymacro.h"
/* clang-format off */
/*[clinic input]
preserve
[clinic start generated code]*/
PyDoc_STRVAR(_imp_lock_held__doc__,
"lock_held($module, /)\n"
"--\n"
"\n"
"Return True if the import lock is currently held, else False.\n"
"\n"
"On platforms without threads, return False.");
"lock_held($module, /)\n"
"--\n"
"\n"
"Return True if the import lock is currently held, else False.\n"
"\n"
"On platforms without threads, return False.");
#define _IMP_LOCK_HELD_METHODDEF \
{"lock_held", (PyCFunction)_imp_lock_held, METH_NOARGS, \
_imp_lock_held__doc__},
#define _IMP_LOCK_HELD_METHODDEF \
{"lock_held", (PyCFunction)_imp_lock_held, METH_NOARGS, _imp_lock_held__doc__},
static PyObject *_imp_lock_held_impl(PyObject *module);
static PyObject *
_imp_lock_held_impl(PyObject *module);
static PyObject *_imp_lock_held(PyObject *module,
PyObject *Py_UNUSED(ignored)) {
return _imp_lock_held_impl(module);
static PyObject *
_imp_lock_held(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _imp_lock_held_impl(module);
}
PyDoc_STRVAR(
_imp_acquire_lock__doc__,
"acquire_lock($module, /)\n"
"--\n"
"\n"
"Acquires the interpreter\'s import lock for the current thread.\n"
"\n"
"This lock should be used by import hooks to ensure thread-safety when "
"importing\n"
"modules. On platforms without threads, this function does nothing.");
PyDoc_STRVAR(_imp_acquire_lock__doc__,
"acquire_lock($module, /)\n"
"--\n"
"\n"
"Acquires the interpreter\'s import lock for the current thread.\n"
"\n"
"This lock should be used by import hooks to ensure thread-safety when importing\n"
"modules. On platforms without threads, this function does nothing.");
#define _IMP_ACQUIRE_LOCK_METHODDEF \
{"acquire_lock", (PyCFunction)_imp_acquire_lock, METH_NOARGS, \
_imp_acquire_lock__doc__},
#define _IMP_ACQUIRE_LOCK_METHODDEF \
{"acquire_lock", (PyCFunction)_imp_acquire_lock, METH_NOARGS, _imp_acquire_lock__doc__},
static PyObject *_imp_acquire_lock_impl(PyObject *module);
static PyObject *
_imp_acquire_lock_impl(PyObject *module);
static PyObject *_imp_acquire_lock(PyObject *module,
PyObject *Py_UNUSED(ignored)) {
return _imp_acquire_lock_impl(module);
static PyObject *
_imp_acquire_lock(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _imp_acquire_lock_impl(module);
}
PyDoc_STRVAR(_imp_release_lock__doc__,
"release_lock($module, /)\n"
"--\n"
"\n"
"Release the interpreter\'s import lock.\n"
"\n"
"On platforms without threads, this function does nothing.");
"release_lock($module, /)\n"
"--\n"
"\n"
"Release the interpreter\'s import lock.\n"
"\n"
"On platforms without threads, this function does nothing.");
#define _IMP_RELEASE_LOCK_METHODDEF \
{"release_lock", (PyCFunction)_imp_release_lock, METH_NOARGS, \
_imp_release_lock__doc__},
#define _IMP_RELEASE_LOCK_METHODDEF \
{"release_lock", (PyCFunction)_imp_release_lock, METH_NOARGS, _imp_release_lock__doc__},
static PyObject *_imp_release_lock_impl(PyObject *module);
static PyObject *
_imp_release_lock_impl(PyObject *module);
static PyObject *_imp_release_lock(PyObject *module,
PyObject *Py_UNUSED(ignored)) {
return _imp_release_lock_impl(module);
static PyObject *
_imp_release_lock(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _imp_release_lock_impl(module);
}
PyDoc_STRVAR(_imp__fix_co_filename__doc__,
"_fix_co_filename($module, code, path, /)\n"
"--\n"
"\n"
"Changes code.co_filename to specify the passed-in file path.\n"
"\n"
" code\n"
" Code object to change.\n"
" path\n"
" File path to use.");
"_fix_co_filename($module, code, path, /)\n"
"--\n"
"\n"
"Changes code.co_filename to specify the passed-in file path.\n"
"\n"
" code\n"
" Code object to change.\n"
" path\n"
" File path to use.");
#define _IMP__FIX_CO_FILENAME_METHODDEF \
{"_fix_co_filename", (PyCFunction)_imp__fix_co_filename, METH_VARARGS, \
_imp__fix_co_filename__doc__},
#define _IMP__FIX_CO_FILENAME_METHODDEF \
{"_fix_co_filename", (PyCFunction)_imp__fix_co_filename, METH_FASTCALL, _imp__fix_co_filename__doc__},
static PyObject *_imp__fix_co_filename_impl(PyObject *module,
PyCodeObject *code, PyObject *path);
static PyObject *
_imp__fix_co_filename_impl(PyObject *module, PyCodeObject *code,
PyObject *path);
static PyObject *_imp__fix_co_filename(PyObject *module, PyObject *args) {
PyObject *return_value = NULL;
PyCodeObject *code;
PyObject *path;
static PyObject *
_imp__fix_co_filename(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyCodeObject *code;
PyObject *path;
if (!PyArg_ParseTuple(args, "O!U:_fix_co_filename", &PyCode_Type, &code,
&path)) {
goto exit;
}
return_value = _imp__fix_co_filename_impl(module, code, path);
if (!_PyArg_ParseStack(args, nargs, "O!U:_fix_co_filename",
&PyCode_Type, &code, &path)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("_fix_co_filename", kwnames)) {
goto exit;
}
return_value = _imp__fix_co_filename_impl(module, code, path);
exit:
return return_value;
return return_value;
}
PyDoc_STRVAR(_imp_create_builtin__doc__, "create_builtin($module, spec, /)\n"
"--\n"
"\n"
"Create an extension module.");
PyDoc_STRVAR(_imp_create_builtin__doc__,
"create_builtin($module, spec, /)\n"
"--\n"
"\n"
"Create an extension module.");
#define _IMP_CREATE_BUILTIN_METHODDEF \
{"create_builtin", (PyCFunction)_imp_create_builtin, METH_O, \
_imp_create_builtin__doc__},
#define _IMP_CREATE_BUILTIN_METHODDEF \
{"create_builtin", (PyCFunction)_imp_create_builtin, METH_O, _imp_create_builtin__doc__},
PyDoc_STRVAR(
_imp_extension_suffixes__doc__,
"extension_suffixes($module, /)\n"
"--\n"
"\n"
"Returns the list of file suffixes used to identify extension modules.");
PyDoc_STRVAR(_imp_extension_suffixes__doc__,
"extension_suffixes($module, /)\n"
"--\n"
"\n"
"Returns the list of file suffixes used to identify extension modules.");
#define _IMP_EXTENSION_SUFFIXES_METHODDEF \
{"extension_suffixes", (PyCFunction)_imp_extension_suffixes, METH_NOARGS, \
_imp_extension_suffixes__doc__},
#define _IMP_EXTENSION_SUFFIXES_METHODDEF \
{"extension_suffixes", (PyCFunction)_imp_extension_suffixes, METH_NOARGS, _imp_extension_suffixes__doc__},
static PyObject *_imp_extension_suffixes_impl(PyObject *module);
static PyObject *
_imp_extension_suffixes_impl(PyObject *module);
static PyObject *_imp_extension_suffixes(PyObject *module,
PyObject *Py_UNUSED(ignored)) {
return _imp_extension_suffixes_impl(module);
static PyObject *
_imp_extension_suffixes(PyObject *module, PyObject *Py_UNUSED(ignored))
{
return _imp_extension_suffixes_impl(module);
}
PyDoc_STRVAR(_imp_init_frozen__doc__, "init_frozen($module, name, /)\n"
"--\n"
"\n"
"Initializes a frozen module.");
PyDoc_STRVAR(_imp_init_frozen__doc__,
"init_frozen($module, name, /)\n"
"--\n"
"\n"
"Initializes a frozen module.");
#define _IMP_INIT_FROZEN_METHODDEF \
{"init_frozen", (PyCFunction)_imp_init_frozen, METH_O, \
_imp_init_frozen__doc__},
#define _IMP_INIT_FROZEN_METHODDEF \
{"init_frozen", (PyCFunction)_imp_init_frozen, METH_O, _imp_init_frozen__doc__},
static PyObject *_imp_init_frozen_impl(PyObject *module, PyObject *name);
static PyObject *
_imp_init_frozen_impl(PyObject *module, PyObject *name);
static PyObject *_imp_init_frozen(PyObject *module, PyObject *arg) {
PyObject *return_value = NULL;
PyObject *name;
static PyObject *
_imp_init_frozen(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:init_frozen", &name)) {
goto exit;
}
return_value = _imp_init_frozen_impl(module, name);
if (!PyArg_Parse(arg, "U:init_frozen", &name)) {
goto exit;
}
return_value = _imp_init_frozen_impl(module, name);
exit:
return return_value;
return return_value;
}
PyDoc_STRVAR(_imp_get_frozen_object__doc__,
"get_frozen_object($module, name, /)\n"
"--\n"
"\n"
"Create a code object for a frozen module.");
"get_frozen_object($module, name, /)\n"
"--\n"
"\n"
"Create a code object for a frozen module.");
#define _IMP_GET_FROZEN_OBJECT_METHODDEF \
{"get_frozen_object", (PyCFunction)_imp_get_frozen_object, METH_O, \
_imp_get_frozen_object__doc__},
#define _IMP_GET_FROZEN_OBJECT_METHODDEF \
{"get_frozen_object", (PyCFunction)_imp_get_frozen_object, METH_O, _imp_get_frozen_object__doc__},
static PyObject *_imp_get_frozen_object_impl(PyObject *module, PyObject *name);
static PyObject *
_imp_get_frozen_object_impl(PyObject *module, PyObject *name);
static PyObject *_imp_get_frozen_object(PyObject *module, PyObject *arg) {
PyObject *return_value = NULL;
PyObject *name;
static PyObject *
_imp_get_frozen_object(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:get_frozen_object", &name)) {
goto exit;
}
return_value = _imp_get_frozen_object_impl(module, name);
if (!PyArg_Parse(arg, "U:get_frozen_object", &name)) {
goto exit;
}
return_value = _imp_get_frozen_object_impl(module, name);
exit:
return return_value;
return return_value;
}
PyDoc_STRVAR(_imp_is_frozen_package__doc__,
"is_frozen_package($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name is of a frozen package.");
"is_frozen_package($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name is of a frozen package.");
#define _IMP_IS_FROZEN_PACKAGE_METHODDEF \
{"is_frozen_package", (PyCFunction)_imp_is_frozen_package, METH_O, \
_imp_is_frozen_package__doc__},
#define _IMP_IS_FROZEN_PACKAGE_METHODDEF \
{"is_frozen_package", (PyCFunction)_imp_is_frozen_package, METH_O, _imp_is_frozen_package__doc__},
static PyObject *_imp_is_frozen_package_impl(PyObject *module, PyObject *name);
static PyObject *
_imp_is_frozen_package_impl(PyObject *module, PyObject *name);
static PyObject *_imp_is_frozen_package(PyObject *module, PyObject *arg) {
PyObject *return_value = NULL;
PyObject *name;
static PyObject *
_imp_is_frozen_package(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:is_frozen_package", &name)) {
goto exit;
}
return_value = _imp_is_frozen_package_impl(module, name);
if (!PyArg_Parse(arg, "U:is_frozen_package", &name)) {
goto exit;
}
return_value = _imp_is_frozen_package_impl(module, name);
exit:
return return_value;
return return_value;
}
PyDoc_STRVAR(
_imp_is_builtin__doc__,
"is_builtin($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name corresponds to a built-in module.");
PyDoc_STRVAR(_imp_is_builtin__doc__,
"is_builtin($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name corresponds to a built-in module.");
#define _IMP_IS_BUILTIN_METHODDEF \
{"is_builtin", (PyCFunction)_imp_is_builtin, METH_O, _imp_is_builtin__doc__},
#define _IMP_IS_BUILTIN_METHODDEF \
{"is_builtin", (PyCFunction)_imp_is_builtin, METH_O, _imp_is_builtin__doc__},
static PyObject *_imp_is_builtin_impl(PyObject *module, PyObject *name);
static PyObject *
_imp_is_builtin_impl(PyObject *module, PyObject *name);
static PyObject *_imp_is_builtin(PyObject *module, PyObject *arg) {
PyObject *return_value = NULL;
PyObject *name;
static PyObject *
_imp_is_builtin(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:is_builtin", &name)) {
goto exit;
}
return_value = _imp_is_builtin_impl(module, name);
if (!PyArg_Parse(arg, "U:is_builtin", &name)) {
goto exit;
}
return_value = _imp_is_builtin_impl(module, name);
exit:
return return_value;
return return_value;
}
PyDoc_STRVAR(_imp_is_frozen__doc__,
"is_frozen($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name corresponds to a frozen module.");
"is_frozen($module, name, /)\n"
"--\n"
"\n"
"Returns True if the module name corresponds to a frozen module.");
#define _IMP_IS_FROZEN_METHODDEF \
{"is_frozen", (PyCFunction)_imp_is_frozen, METH_O, _imp_is_frozen__doc__},
#define _IMP_IS_FROZEN_METHODDEF \
{"is_frozen", (PyCFunction)_imp_is_frozen, METH_O, _imp_is_frozen__doc__},
static PyObject *_imp_is_frozen_impl(PyObject *module, PyObject *name);
static PyObject *
_imp_is_frozen_impl(PyObject *module, PyObject *name);
static PyObject *_imp_is_frozen(PyObject *module, PyObject *arg) {
PyObject *return_value = NULL;
PyObject *name;
static PyObject *
_imp_is_frozen(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
PyObject *name;
if (!PyArg_Parse(arg, "U:is_frozen", &name)) {
goto exit;
}
return_value = _imp_is_frozen_impl(module, name);
if (!PyArg_Parse(arg, "U:is_frozen", &name)) {
goto exit;
}
return_value = _imp_is_frozen_impl(module, name);
exit:
return return_value;
return return_value;
}
#if defined(HAVE_DYNAMIC_LOADING)
PyDoc_STRVAR(_imp_create_dynamic__doc__,
"create_dynamic($module, spec, file=None, /)\n"
"--\n"
"\n"
"Create an extension module.");
"create_dynamic($module, spec, file=None, /)\n"
"--\n"
"\n"
"Create an extension module.");
#define _IMP_CREATE_DYNAMIC_METHODDEF \
{"create_dynamic", (PyCFunction)_imp_create_dynamic, METH_VARARGS, \
_imp_create_dynamic__doc__},
#define _IMP_CREATE_DYNAMIC_METHODDEF \
{"create_dynamic", (PyCFunction)_imp_create_dynamic, METH_FASTCALL, _imp_create_dynamic__doc__},
static PyObject *_imp_create_dynamic_impl(PyObject *module, PyObject *spec,
PyObject *file);
static PyObject *
_imp_create_dynamic_impl(PyObject *module, PyObject *spec, PyObject *file);
static PyObject *_imp_create_dynamic(PyObject *module, PyObject *args) {
PyObject *return_value = NULL;
PyObject *spec;
PyObject *file = NULL;
static PyObject *
_imp_create_dynamic(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
PyObject *spec;
PyObject *file = NULL;
if (!PyArg_UnpackTuple(args, "create_dynamic", 1, 2, &spec, &file)) {
goto exit;
}
return_value = _imp_create_dynamic_impl(module, spec, file);
if (!_PyArg_UnpackStack(args, nargs, "create_dynamic",
1, 2,
&spec, &file)) {
goto exit;
}
if (!_PyArg_NoStackKeywords("create_dynamic", kwnames)) {
goto exit;
}
return_value = _imp_create_dynamic_impl(module, spec, file);
exit:
return return_value;
return return_value;
}
#endif /* defined(HAVE_DYNAMIC_LOADING) */
#if defined(HAVE_DYNAMIC_LOADING)
PyDoc_STRVAR(_imp_exec_dynamic__doc__, "exec_dynamic($module, mod, /)\n"
"--\n"
"\n"
"Initialize an extension module.");
PyDoc_STRVAR(_imp_exec_dynamic__doc__,
"exec_dynamic($module, mod, /)\n"
"--\n"
"\n"
"Initialize an extension module.");
#define _IMP_EXEC_DYNAMIC_METHODDEF \
{"exec_dynamic", (PyCFunction)_imp_exec_dynamic, METH_O, \
_imp_exec_dynamic__doc__},
#define _IMP_EXEC_DYNAMIC_METHODDEF \
{"exec_dynamic", (PyCFunction)_imp_exec_dynamic, METH_O, _imp_exec_dynamic__doc__},
static int _imp_exec_dynamic_impl(PyObject *module, PyObject *mod);
static int
_imp_exec_dynamic_impl(PyObject *module, PyObject *mod);
static PyObject *_imp_exec_dynamic(PyObject *module, PyObject *mod) {
PyObject *return_value = NULL;
int _return_value;
static PyObject *
_imp_exec_dynamic(PyObject *module, PyObject *mod)
{
PyObject *return_value = NULL;
int _return_value;
_return_value = _imp_exec_dynamic_impl(module, mod);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyLong_FromLong((long)_return_value);
_return_value = _imp_exec_dynamic_impl(module, mod);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyLong_FromLong((long)_return_value);
exit:
return return_value;
return return_value;
}
#endif /* defined(HAVE_DYNAMIC_LOADING) */
PyDoc_STRVAR(_imp_exec_builtin__doc__, "exec_builtin($module, mod, /)\n"
"--\n"
"\n"
"Initialize a built-in module.");
PyDoc_STRVAR(_imp_exec_builtin__doc__,
"exec_builtin($module, mod, /)\n"
"--\n"
"\n"
"Initialize a built-in module.");
#define _IMP_EXEC_BUILTIN_METHODDEF \
{"exec_builtin", (PyCFunction)_imp_exec_builtin, METH_O, \
_imp_exec_builtin__doc__},
#define _IMP_EXEC_BUILTIN_METHODDEF \
{"exec_builtin", (PyCFunction)_imp_exec_builtin, METH_O, _imp_exec_builtin__doc__},
static int _imp_exec_builtin_impl(PyObject *module, PyObject *mod);
static int
_imp_exec_builtin_impl(PyObject *module, PyObject *mod);
static PyObject *_imp_exec_builtin(PyObject *module, PyObject *mod) {
PyObject *return_value = NULL;
int _return_value;
static PyObject *
_imp_exec_builtin(PyObject *module, PyObject *mod)
{
PyObject *return_value = NULL;
int _return_value;
_return_value = _imp_exec_builtin_impl(module, mod);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyLong_FromLong((long)_return_value);
_return_value = _imp_exec_builtin_impl(module, mod);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyLong_FromLong((long)_return_value);
exit:
return return_value;
return return_value;
}
#ifndef _IMP_CREATE_DYNAMIC_METHODDEF
#define _IMP_CREATE_DYNAMIC_METHODDEF
#define _IMP_CREATE_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_CREATE_DYNAMIC_METHODDEF) */
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
/*[clinic end generated code: output=d24d7f73702a907f input=a9049054013a1b77]*/
/*[clinic end generated code: output=c1d0e65d04114958 input=a9049054013a1b77]*/

File diff suppressed because it is too large Load diff

View file

@ -1688,7 +1688,7 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
/* And an interface for Python programs... */
static PyObject *
marshal_dump(PyObject *self, PyObject *args)
marshal_dump(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
/* XXX Quick hack -- need to do this differently */
PyObject *x;
@ -1698,8 +1698,11 @@ marshal_dump(PyObject *self, PyObject *args)
PyObject *res;
_Py_IDENTIFIER(write);
if (!PyArg_ParseTuple(args, "OO|i:dump", &x, &f, &version))
if (!_PyArg_ParseStack(args, nargs, "OO|i:dump", &x, &f, &version))
return NULL;
if (!_PyArg_NoStackKeywords("dump", kwnames))
return NULL;
s = PyMarshal_WriteObjectToString(x, version);
if (s == NULL)
return NULL;
@ -1775,11 +1778,13 @@ dump(), load() will substitute None for the unmarshallable type.");
static PyObject *
marshal_dumps(PyObject *self, PyObject *args)
marshal_dumps(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *x;
int version = Py_MARSHAL_VERSION;
if (!PyArg_ParseTuple(args, "O|i:dumps", &x, &version))
if (!_PyArg_ParseStack(args, nargs, "O|i:dumps", &x, &version))
return NULL;
if(!_PyArg_NoStackKeywords("dumps", kwnames))
return NULL;
return PyMarshal_WriteObjectToString(x, version);
}
@ -1795,14 +1800,16 @@ The version argument indicates the data format that dumps should use.");
static PyObject *
marshal_loads(PyObject *self, PyObject *args)
marshal_loads(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
{
RFILE rf;
Py_buffer p;
char *s;
Py_ssize_t n;
PyObject* result;
if (!PyArg_ParseTuple(args, "y*:loads", &p))
if (!_PyArg_ParseStack(args, nargs, "y*:loads", &p))
return NULL;
if(!_PyArg_NoStackKeywords("loads", kwnames))
return NULL;
s = p.buf;
n = p.len;
@ -1828,10 +1835,10 @@ raise EOFError, ValueError or TypeError. Extra bytes in the input are\n\
ignored.");
static PyMethodDef marshal_methods[] = {
{"dump", marshal_dump, METH_VARARGS, dump_doc},
{"dump", (PyCFunction)marshal_dump, METH_FASTCALL, dump_doc},
{"load", marshal_load, METH_O, load_doc},
{"dumps", marshal_dumps, METH_VARARGS, dumps_doc},
{"loads", marshal_loads, METH_VARARGS, loads_doc},
{"dumps", (PyCFunction)marshal_dumps, METH_FASTCALL, dumps_doc},
{"loads", (PyCFunction)marshal_loads, METH_FASTCALL, loads_doc},
{NULL, NULL} /* sentinel */
};