summaryrefslogtreecommitdiffstats
path: root/Modules/zlibmodule.c
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-04-01 14:53:37 (GMT)
committerFred Drake <fdrake@acm.org>2002-04-01 14:53:37 (GMT)
commit4baedc1d9be6e5308d73439db54b58e51fb30dfc (patch)
treefb69c6411b2d7be1d2c09e0717329789ec8953ca /Modules/zlibmodule.c
parent9bb7432114c97ad99c0813c1fef1ef4f1cda3361 (diff)
downloadcpython-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.c17
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();