blob: 4c54483fe6e5cd00c9e2d43b0342e317270e0ed8 [file] [log] [blame]
Serhiy Storchaka18b250f2017-03-19 08:51:07 +02001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(func_new__doc__,
6"function(code, globals, name=None, argdefs=None, closure=None)\n"
7"--\n"
8"\n"
9"Create a function object.\n"
10"\n"
11" code\n"
12" a code object\n"
13" globals\n"
14" the globals dictionary\n"
15" name\n"
16" a string that overrides the name from the code object\n"
17" argdefs\n"
18" a tuple that specifies the default argument values\n"
19" closure\n"
20" a tuple that supplies the bindings for free variables");
21
22static PyObject *
23func_new_impl(PyTypeObject *type, PyCodeObject *code, PyObject *globals,
24 PyObject *name, PyObject *defaults, PyObject *closure);
25
26static PyObject *
27func_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
28{
29 PyObject *return_value = NULL;
30 static const char * const _keywords[] = {"code", "globals", "name", "argdefs", "closure", NULL};
31 static _PyArg_Parser _parser = {"O!O!|OOO:function", _keywords, 0};
32 PyCodeObject *code;
33 PyObject *globals;
34 PyObject *name = Py_None;
35 PyObject *defaults = Py_None;
36 PyObject *closure = Py_None;
37
38 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
39 &PyCode_Type, &code, &PyDict_Type, &globals, &name, &defaults, &closure)) {
40 goto exit;
41 }
42 return_value = func_new_impl(type, code, globals, name, defaults, closure);
43
44exit:
45 return return_value;
46}
47/*[clinic end generated code: output=a6ab29e4dd33010a input=a9049054013a1b77]*/