Serhiy Storchaka | 18b250f | 2017-03-19 08:51:07 +0200 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(module___init____doc__, |
| 6 | "module(name, doc=None)\n" |
| 7 | "--\n" |
| 8 | "\n" |
| 9 | "Create a module object.\n" |
| 10 | "\n" |
| 11 | "The name must be a string; the optional doc argument can have any type."); |
| 12 | |
| 13 | static int |
| 14 | module___init___impl(PyModuleObject *self, PyObject *name, PyObject *doc); |
| 15 | |
| 16 | static int |
| 17 | module___init__(PyObject *self, PyObject *args, PyObject *kwargs) |
| 18 | { |
| 19 | int return_value = -1; |
| 20 | static const char * const _keywords[] = {"name", "doc", NULL}; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 21 | static _PyArg_Parser _parser = {NULL, _keywords, "module", 0}; |
| 22 | PyObject *argsbuf[2]; |
| 23 | PyObject * const *fastargs; |
| 24 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
| 25 | Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1; |
Serhiy Storchaka | 18b250f | 2017-03-19 08:51:07 +0200 | [diff] [blame] | 26 | PyObject *name; |
| 27 | PyObject *doc = Py_None; |
| 28 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 29 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 2, 0, argsbuf); |
| 30 | if (!fastargs) { |
Serhiy Storchaka | 18b250f | 2017-03-19 08:51:07 +0200 | [diff] [blame] | 31 | goto exit; |
| 32 | } |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 33 | if (!PyUnicode_Check(fastargs[0])) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 34 | _PyArg_BadArgument("module", "argument 'name'", "str", fastargs[0]); |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 35 | goto exit; |
| 36 | } |
| 37 | if (PyUnicode_READY(fastargs[0]) == -1) { |
| 38 | goto exit; |
| 39 | } |
| 40 | name = fastargs[0]; |
| 41 | if (!noptargs) { |
| 42 | goto skip_optional_pos; |
| 43 | } |
| 44 | doc = fastargs[1]; |
| 45 | skip_optional_pos: |
Serhiy Storchaka | 18b250f | 2017-03-19 08:51:07 +0200 | [diff] [blame] | 46 | return_value = module___init___impl((PyModuleObject *)self, name, doc); |
| 47 | |
| 48 | exit: |
| 49 | return return_value; |
| 50 | } |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame] | 51 | /*[clinic end generated code: output=680276bc3a496d7a input=a9049054013a1b77]*/ |