summaryrefslogtreecommitdiffstats
path: root/Modules/zlibmodule.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/zlibmodule.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/zlibmodule.c')
-rw-r--r--Modules/zlibmodule.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c
index 0be9d6f..e63063f 100644
--- a/Modules/zlibmodule.c
+++ b/Modules/zlibmodule.c
@@ -53,7 +53,6 @@ static PyThread_type_lock zlib_lock = NULL; /* initialized on module load */
/* The output buffer will be increased in chunks of DEFAULTALLOC bytes. */
#define DEFAULTALLOC (16*1024)
-#define PyInit_zlib initzlib
static PyTypeObject Comptype;
static PyTypeObject Decomptype;
@@ -1013,17 +1012,27 @@ PyDoc_STRVAR(zlib_module_documentation,
"Compressor objects support compress() and flush() methods; decompressor\n"
"objects support decompress() and flush().");
+static struct PyModuleDef zlibmodule = {
+ PyModuleDef_HEAD_INIT,
+ "zlib",
+ zlib_module_documentation,
+ -1,
+ zlib_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
PyInit_zlib(void)
{
PyObject *m, *ver;
Py_TYPE(&Comptype) = &PyType_Type;
Py_TYPE(&Decomptype) = &PyType_Type;
- m = Py_InitModule4("zlib", zlib_methods,
- zlib_module_documentation,
- (PyObject*)NULL,PYTHON_API_VERSION);
+ m = PyModule_Create(&zlibmodule);
if (m == NULL)
- return;
+ return NULL;
ZlibError = PyErr_NewException("zlib.error", NULL, NULL);
if (ZlibError != NULL) {
@@ -1054,4 +1063,5 @@ PyInit_zlib(void)
#ifdef WITH_THREAD
zlib_lock = PyThread_allocate_lock();
#endif /* WITH_THREAD */
+ return m;
}