Py_InitModule4(): Accept NULL for the 'methods' argument. This makes

sense now that extension types can support __init__ directly rather
than requiring function constructors.
This commit is contained in:
Fred Drake 2002-08-14 20:57:56 +00:00
parent 92bb6e7b96
commit 233cc5987b
1 changed files with 16 additions and 14 deletions

View File

@ -56,6 +56,7 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc,
if ((m = PyImport_AddModule(name)) == NULL)
return NULL;
d = PyModule_GetDict(m);
if (methods != NULL) {
for (ml = methods; ml->ml_name != NULL; ml++) {
if ((ml->ml_flags & METH_CLASS) ||
(ml->ml_flags & METH_STATIC)) {
@ -73,6 +74,7 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc,
}
Py_DECREF(v);
}
}
if (doc != NULL) {
v = PyString_FromString(doc);
if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) {