diff options
author | Fred Drake <fdrake@acm.org> | 2002-02-14 07:11:23 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2002-02-14 07:11:23 (GMT) |
commit | 78f6c867aeb33037abc77afd8f4a0f1d44386676 (patch) | |
tree | 25046ebf8f17bb6ade37a4ed48a5980f91581046 /Modules/structmodule.c | |
parent | cca657b8fefa26eadd5c8362813d8b93dded3a46 (diff) | |
download | cpython-78f6c867aeb33037abc77afd8f4a0f1d44386676.zip cpython-78f6c867aeb33037abc77afd8f4a0f1d44386676.tar.gz cpython-78f6c867aeb33037abc77afd8f4a0f1d44386676.tar.bz2 |
Use PyModule_AddObject() instead of accessing the module dict directly.
Diffstat (limited to 'Modules/structmodule.c')
-rw-r--r-- | Modules/structmodule.c | 14 |
1 files changed, 8 insertions, 6 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); } |