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/stropmodule.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/stropmodule.c')
-rw-r--r-- | Modules/stropmodule.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index 3c69fb3..9af9312 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -1215,12 +1215,11 @@ strop_methods[] = { DL_EXPORT(void) initstrop(void) { - PyObject *m, *d, *s; + PyObject *m, *s; char buf[256]; int c, n; m = Py_InitModule4("strop", strop_methods, strop_module__doc__, (PyObject*)NULL, PYTHON_API_VERSION); - d = PyModule_GetDict(m); /* Create 'whitespace' object */ n = 0; @@ -1229,10 +1228,9 @@ initstrop(void) buf[n++] = c; } s = PyString_FromStringAndSize(buf, n); - if (s) { - PyDict_SetItemString(d, "whitespace", s); - Py_DECREF(s); - } + if (s) + PyModule_AddObject(m, "whitespace", s); + /* Create 'lowercase' object */ n = 0; for (c = 0; c < 256; c++) { @@ -1240,10 +1238,8 @@ initstrop(void) buf[n++] = c; } s = PyString_FromStringAndSize(buf, n); - if (s) { - PyDict_SetItemString(d, "lowercase", s); - Py_DECREF(s); - } + if (s) + PyModule_AddObject(m, "lowercase", s); /* Create 'uppercase' object */ n = 0; @@ -1252,8 +1248,6 @@ initstrop(void) buf[n++] = c; } s = PyString_FromStringAndSize(buf, n); - if (s) { - PyDict_SetItemString(d, "uppercase", s); - Py_DECREF(s); - } + if (s) + PyModule_AddObject(m, "uppercase", s); } |