diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-19 06:51:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-19 06:51:07 (GMT) |
commit | 18b250f844bf8b2d1a81c2d2dcc74e850364fe35 (patch) | |
tree | 117c9240b5b87067a07cb43bc9260ed26c3148bb /Objects/moduleobject.c | |
parent | 0b5615926a573c19c887a701a2f7047f4fd06de6 (diff) | |
download | cpython-18b250f844bf8b2d1a81c2d2dcc74e850364fe35.zip cpython-18b250f844bf8b2d1a81c2d2dcc74e850364fe35.tar.gz cpython-18b250f844bf8b2d1a81c2d2dcc74e850364fe35.tar.bz2 |
bpo-29793: Convert some builtin types constructors to Argument Clinic. (#615)
Diffstat (limited to 'Objects/moduleobject.c')
-rw-r--r-- | Objects/moduleobject.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 350f3bf..02a8cf0 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -607,24 +607,37 @@ _PyModule_ClearDict(PyObject *d) } +/*[clinic input] +class module "PyModuleObject *" "&PyModule_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=3e35d4f708ecb6af]*/ + +#include "clinic/moduleobject.c.h" + /* Methods */ +/*[clinic input] +module.__init__ + name: unicode + doc: object = None + +Create a module object. + +The name must be a string; the optional doc argument can have any type. +[clinic start generated code]*/ + static int -module_init(PyModuleObject *m, PyObject *args, PyObject *kwds) +module___init___impl(PyModuleObject *self, PyObject *name, PyObject *doc) +/*[clinic end generated code: output=e7e721c26ce7aad7 input=57f9e177401e5e1e]*/ { - static char *kwlist[] = {"name", "doc", NULL}; - PyObject *dict, *name = Py_None, *doc = Py_None; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "U|O:module.__init__", - kwlist, &name, &doc)) - return -1; - dict = m->md_dict; + PyObject *dict = self->md_dict; if (dict == NULL) { dict = PyDict_New(); if (dict == NULL) return -1; - m->md_dict = dict; + self->md_dict = dict; } - if (module_init_dict(m, dict, name, doc) < 0) + if (module_init_dict(self, dict, name, doc) < 0) return -1; return 0; } @@ -734,12 +747,6 @@ static PyMethodDef module_methods[] = { {0} }; -PyDoc_STRVAR(module_doc, -"module(name[, doc])\n\ -\n\ -Create a module object.\n\ -The name must be a string; the optional doc argument can have any type."); - PyTypeObject PyModule_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "module", /* tp_name */ @@ -762,7 +769,7 @@ PyTypeObject PyModule_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */ - module_doc, /* tp_doc */ + module___init____doc__, /* tp_doc */ (traverseproc)module_traverse, /* tp_traverse */ (inquiry)module_clear, /* tp_clear */ 0, /* tp_richcompare */ @@ -777,7 +784,7 @@ PyTypeObject PyModule_Type = { 0, /* tp_descr_get */ 0, /* tp_descr_set */ offsetof(PyModuleObject, md_dict), /* tp_dictoffset */ - (initproc)module_init, /* tp_init */ + module___init__, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ PyType_GenericNew, /* tp_new */ PyObject_GC_Del, /* tp_free */ |