summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-08-14 20:57:56 (GMT)
committerFred Drake <fdrake@acm.org>2002-08-14 20:57:56 (GMT)
commit233cc5987b6659d0fcd033a420ad8b5390ffa772 (patch)
tree1723cab24bf968fd28c609113c4669b33f23599e /Python
parent92bb6e7b96d7b8a26ef797d5b0046d7b6c310e60 (diff)
downloadcpython-233cc5987b6659d0fcd033a420ad8b5390ffa772.zip
cpython-233cc5987b6659d0fcd033a420ad8b5390ffa772.tar.gz
cpython-233cc5987b6659d0fcd033a420ad8b5390ffa772.tar.bz2
Py_InitModule4(): Accept NULL for the 'methods' argument. This makes
sense now that extension types can support __init__ directly rather than requiring function constructors.
Diffstat (limited to 'Python')
-rw-r--r--Python/modsupport.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 1f8ef07..98b0341 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -56,22 +56,24 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc,
if ((m = PyImport_AddModule(name)) == NULL)
return NULL;
d = PyModule_GetDict(m);
- for (ml = methods; ml->ml_name != NULL; ml++) {
- if ((ml->ml_flags & METH_CLASS) ||
- (ml->ml_flags & METH_STATIC)) {
- PyErr_SetString(PyExc_ValueError,
- "module functions cannot set"
- " METH_CLASS or METH_STATIC");
- return NULL;
- }
- v = PyCFunction_New(ml, passthrough);
- if (v == NULL)
- return NULL;
- if (PyDict_SetItemString(d, ml->ml_name, v) != 0) {
+ if (methods != NULL) {
+ for (ml = methods; ml->ml_name != NULL; ml++) {
+ if ((ml->ml_flags & METH_CLASS) ||
+ (ml->ml_flags & METH_STATIC)) {
+ PyErr_SetString(PyExc_ValueError,
+ "module functions cannot set"
+ " METH_CLASS or METH_STATIC");
+ return NULL;
+ }
+ v = PyCFunction_New(ml, passthrough);
+ if (v == NULL)
+ return NULL;
+ if (PyDict_SetItemString(d, ml->ml_name, v) != 0) {
+ Py_DECREF(v);
+ return NULL;
+ }
Py_DECREF(v);
- return NULL;
}
- Py_DECREF(v);
}
if (doc != NULL) {
v = PyString_FromString(doc);