summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-02-14 07:11:23 (GMT)
committerFred Drake <fdrake@acm.org>2002-02-14 07:11:23 (GMT)
commit78f6c867aeb33037abc77afd8f4a0f1d44386676 (patch)
tree25046ebf8f17bb6ade37a4ed48a5980f91581046 /Modules
parentcca657b8fefa26eadd5c8362813d8b93dded3a46 (diff)
downloadcpython-78f6c867aeb33037abc77afd8f4a0f1d44386676.zip
cpython-78f6c867aeb33037abc77afd8f4a0f1d44386676.tar.gz
cpython-78f6c867aeb33037abc77afd8f4a0f1d44386676.tar.bz2
Use PyModule_AddObject() instead of accessing the module dict directly.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/structmodule.c14
-rw-r--r--Modules/termios.c10
2 files changed, 14 insertions, 10 deletions
diff --git a/Modules/structmodule.c b/Modules/structmodule.c
index 8cc4945..86ac366 100644
--- a/Modules/structmodule.c
+++ b/Modules/structmodule.c
@@ -1502,16 +1502,18 @@ static PyMethodDef struct_methods[] = {
DL_EXPORT(void)
initstruct(void)
{
- PyObject *m, *d;
+ PyObject *m;
/* Create the module and add the functions */
m = Py_InitModule4("struct", struct_methods, struct__doc__,
(PyObject*)NULL, PYTHON_API_VERSION);
/* Add some symbolic constants to the module */
- d = PyModule_GetDict(m);
- StructError = PyErr_NewException("struct.error", NULL, NULL);
- if (StructError == NULL)
- return;
- PyDict_SetItemString(d, "error", StructError);
+ if (StructError == NULL) {
+ StructError = PyErr_NewException("struct.error", NULL, NULL);
+ if (StructError == NULL)
+ return;
+ }
+ Py_INCREF(StructError);
+ PyModule_AddObject(d, "error", StructError);
}
diff --git a/Modules/termios.c b/Modules/termios.c
index 3362e81..aaabe60 100644
--- a/Modules/termios.c
+++ b/Modules/termios.c
@@ -891,15 +891,17 @@ static struct constant {
DL_EXPORT(void)
PyInit_termios(void)
{
- PyObject *m, *d;
+ PyObject *m;
struct constant *constant = termios_constants;
m = Py_InitModule4("termios", termios_methods, termios__doc__,
(PyObject *)NULL, PYTHON_API_VERSION);
- d = PyModule_GetDict(m);
- TermiosError = PyErr_NewException("termios.error", NULL, NULL);
- PyDict_SetItemString(d, "error", TermiosError);
+ if (TermiosError == NULL) {
+ TermiosError = PyErr_NewException("termios.error", NULL, NULL);
+ }
+ Py_INCREF(TermiosError);
+ PyModule_AddObject(m, "error", TermiosError);
while (constant->name != NULL) {
PyModule_AddIntConstant(m, constant->name, constant->value);