summaryrefslogtreecommitdiffstats
path: root/Modules/_csv.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
commit1a21451b1d73b65af949193208372e86bf308411 (patch)
tree8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/_csv.c
parentcdf94635d7e364f9ce1905bafa5b540f4d16147c (diff)
downloadcpython-1a21451b1d73b65af949193208372e86bf308411.zip
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r--Modules/_csv.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 9a72955..c654712 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -1542,53 +1542,67 @@ static struct PyMethodDef csv_methods[] = {
{ NULL, NULL }
};
+
+static struct PyModuleDef _csvmodule = {
+ PyModuleDef_HEAD_INIT,
+ "_csv",
+ csv_module_doc,
+ -1,
+ csv_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
-init_csv(void)
+PyInit__csv(void)
{
PyObject *module;
StyleDesc *style;
if (PyType_Ready(&Dialect_Type) < 0)
- return;
+ return NULL;
if (PyType_Ready(&Reader_Type) < 0)
- return;
+ return NULL;
if (PyType_Ready(&Writer_Type) < 0)
- return;
+ return NULL;
/* Create the module and add the functions */
- module = Py_InitModule3("_csv", csv_methods, csv_module_doc);
+ module = PyModule_Create(&_csvmodule);
if (module == NULL)
- return;
+ return NULL;
/* Add version to the module. */
if (PyModule_AddStringConstant(module, "__version__",
MODULE_VERSION) == -1)
- return;
+ return NULL;
/* Add _dialects dictionary */
dialects = PyDict_New();
if (dialects == NULL)
- return;
+ return NULL;
if (PyModule_AddObject(module, "_dialects", dialects))
- return;
+ return NULL;
/* Add quote styles into dictionary */
for (style = quote_styles; style->name; style++) {
if (PyModule_AddIntConstant(module, style->name,
style->style) == -1)
- return;
+ return NULL;
}
/* Add the Dialect type */
Py_INCREF(&Dialect_Type);
if (PyModule_AddObject(module, "Dialect", (PyObject *)&Dialect_Type))
- return;
+ return NULL;
/* Add the CSV exception object to the module. */
error_obj = PyErr_NewException("_csv.Error", NULL, NULL);
if (error_obj == NULL)
- return;
+ return NULL;
PyModule_AddObject(module, "Error", error_obj);
+ return module;
}