Kaydet (Commit) 233cc598 authored tarafından Fred Drake's avatar Fred Drake

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

sense now that extension types can support __init__ directly rather
than requiring function constructors.
üst 92bb6e7b
...@@ -56,6 +56,7 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc, ...@@ -56,6 +56,7 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc,
if ((m = PyImport_AddModule(name)) == NULL) if ((m = PyImport_AddModule(name)) == NULL)
return NULL; return NULL;
d = PyModule_GetDict(m); d = PyModule_GetDict(m);
if (methods != NULL) {
for (ml = methods; ml->ml_name != NULL; ml++) { for (ml = methods; ml->ml_name != NULL; ml++) {
if ((ml->ml_flags & METH_CLASS) || if ((ml->ml_flags & METH_CLASS) ||
(ml->ml_flags & METH_STATIC)) { (ml->ml_flags & METH_STATIC)) {
...@@ -73,6 +74,7 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc, ...@@ -73,6 +74,7 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc,
} }
Py_DECREF(v); Py_DECREF(v);
} }
}
if (doc != NULL) { if (doc != NULL) {
v = PyString_FromString(doc); v = PyString_FromString(doc);
if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) { if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment