mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-29793: Convert some builtin types constructors to Argument Clinic. (#615)
This commit is contained in:
parent
0b5615926a
commit
18b250f844
14 changed files with 527 additions and 202 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue