diff options
author | Fred Drake <fdrake@acm.org> | 2002-04-01 14:53:37 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-04-01 14:53:37 (GMT) |
commit | 4baedc1d9be6e5308d73439db54b58e51fb30dfc (patch) | |
tree | fb69c6411b2d7be1d2c09e0717329789ec8953ca /Modules/zlibmodule.c | |
parent | 9bb7432114c97ad99c0813c1fef1ef4f1cda3361 (diff) | |
download | cpython-4baedc1d9be6e5308d73439db54b58e51fb30dfc.zip cpython-4baedc1d9be6e5308d73439db54b58e51fb30dfc.tar.gz cpython-4baedc1d9be6e5308d73439db54b58e51fb30dfc.tar.bz2 |
Use the PyModule_Add*() APIs instead of manipulating the module dict
directly.
Diffstat (limited to 'Modules/zlibmodule.c')
-rw-r--r-- | Modules/zlibmodule.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index feb52ea..8fc3bc2 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -847,17 +847,18 @@ static char zlib_module_documentation[]= DL_EXPORT(void) PyInit_zlib(void) { - PyObject *m, *d, *ver; + PyObject *m, *ver; Comptype.ob_type = &PyType_Type; Decomptype.ob_type = &PyType_Type; m = Py_InitModule4("zlib", zlib_methods, zlib_module_documentation, (PyObject*)NULL,PYTHON_API_VERSION); - d = PyModule_GetDict(m); - ZlibError = PyErr_NewException("zlib.error", NULL, NULL); - if (ZlibError != NULL) - PyDict_SetItemString(d, "error", ZlibError); + ZlibError = PyErr_NewException("zlib.error", NULL, NULL); + if (ZlibError != NULL) { + Py_INCREF(ZlibError); + PyModule_AddObject(m, "error", ZlibError); + } PyModule_AddIntConstant(m, "MAX_WBITS", MAX_WBITS); PyModule_AddIntConstant(m, "DEFLATED", DEFLATED); PyModule_AddIntConstant(m, "DEF_MEM_LEVEL", DEF_MEM_LEVEL); @@ -874,10 +875,8 @@ PyInit_zlib(void) PyModule_AddIntConstant(m, "Z_FULL_FLUSH", Z_FULL_FLUSH); ver = PyString_FromString(ZLIB_VERSION); - if (ver != NULL) { - PyDict_SetItemString(d, "ZLIB_VERSION", ver); - Py_DECREF(ver); - } + if (ver != NULL) + PyModule_AddObject(m, "ZLIB_VERSION", ver); #ifdef WITH_THREAD zlib_lock = PyThread_allocate_lock(); |