summaryrefslogtreecommitdiffstats
path: root/Objects/codeobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2020-07-10 07:12:04 (GMT)
committerGitHub <noreply@github.com>2020-07-10 07:12:04 (GMT)
commit0f9aa47babbfbecc5ef500fb0feae755230ec3c0 (patch)
treed5e674e58a4475e1f671b1127debc957dfc3ea94 /Objects/codeobject.c
parent3cbade7d309ab1ea97ec286d19d506df30bd1ab7 (diff)
downloadcpython-0f9aa47babbfbecc5ef500fb0feae755230ec3c0.zip
cpython-0f9aa47babbfbecc5ef500fb0feae755230ec3c0.tar.gz
cpython-0f9aa47babbfbecc5ef500fb0feae755230ec3c0.tar.bz2
bpo-41263: Convert code.__new__ to Argument Clinic (GH-21426)
Diffstat (limited to 'Objects/codeobject.c')
-rw-r--r--Objects/codeobject.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 49011db..4ca22fc 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -442,46 +442,45 @@ validate_and_copy_tuple(PyObject *tup)
return newtuple;
}
-PyDoc_STRVAR(code_doc,
-"code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,\n\
- flags, codestring, constants, names, varnames, filename, name,\n\
- firstlineno, lnotab[, freevars[, cellvars]])\n\
-\n\
-Create a code object. Not for the faint of heart.");
+/*[clinic input]
+@classmethod
+code.__new__ as code_new
+
+ argcount: int
+ posonlyargcount: int
+ kwonlyargcount: int
+ nlocals: int
+ stacksize: int
+ flags: int
+ codestring as code: object(subclass_of="&PyBytes_Type")
+ constants as consts: object(subclass_of="&PyTuple_Type")
+ names: object(subclass_of="&PyTuple_Type")
+ varnames: object(subclass_of="&PyTuple_Type")
+ filename: unicode
+ name: unicode
+ firstlineno: int
+ lnotab: object(subclass_of="&PyBytes_Type")
+ freevars: object(subclass_of="&PyTuple_Type", c_default="NULL") = ()
+ cellvars: object(subclass_of="&PyTuple_Type", c_default="NULL") = ()
+ /
+
+Create a code object. Not for the faint of heart.
+[clinic start generated code]*/
static PyObject *
-code_new(PyTypeObject *type, PyObject *args, PyObject *kw)
+code_new_impl(PyTypeObject *type, int argcount, int posonlyargcount,
+ int kwonlyargcount, int nlocals, int stacksize, int flags,
+ PyObject *code, PyObject *consts, PyObject *names,
+ PyObject *varnames, PyObject *filename, PyObject *name,
+ int firstlineno, PyObject *lnotab, PyObject *freevars,
+ PyObject *cellvars)
+/*[clinic end generated code: output=612aac5395830184 input=85e678ea4178f234]*/
{
- int argcount;
- int posonlyargcount;
- int kwonlyargcount;
- int nlocals;
- int stacksize;
- int flags;
PyObject *co = NULL;
- PyObject *code;
- PyObject *consts;
- PyObject *names, *ournames = NULL;
- PyObject *varnames, *ourvarnames = NULL;
- PyObject *freevars = NULL, *ourfreevars = NULL;
- PyObject *cellvars = NULL, *ourcellvars = NULL;
- PyObject *filename;
- PyObject *name;
- int firstlineno;
- PyObject *lnotab;
-
- if (!PyArg_ParseTuple(args, "iiiiiiSO!O!O!UUiS|O!O!:code",
- &argcount, &posonlyargcount, &kwonlyargcount,
- &nlocals, &stacksize, &flags,
- &code,
- &PyTuple_Type, &consts,
- &PyTuple_Type, &names,
- &PyTuple_Type, &varnames,
- &filename, &name,
- &firstlineno, &lnotab,
- &PyTuple_Type, &freevars,
- &PyTuple_Type, &cellvars))
- return NULL;
+ PyObject *ournames = NULL;
+ PyObject *ourvarnames = NULL;
+ PyObject *ourfreevars = NULL;
+ PyObject *ourcellvars = NULL;
if (PySys_Audit("code.__new__", "OOOiiiiii",
code, filename, name, argcount, posonlyargcount,
@@ -963,7 +962,7 @@ PyTypeObject PyCode_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
- code_doc, /* tp_doc */
+ code_new__doc__, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
code_richcompare, /* tp_richcompare */