Mercurial > cpython-lru_cache-weakref
diff Modules/structmodule.c @ 21944:f39213405e05 legacy-trunk
Use PyModule_AddObject() instead of accessing the module dict directly.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Thu, 14 Feb 2002 07:11:23 +0000 |
| parents | edd9d0b3c47e |
| children | cbf1dbca1f63 |
line wrap: on
line diff
--- a/Modules/structmodule.c Thu Feb 14 06:59:26 2002 +0000 +++ b/Modules/structmodule.c Thu Feb 14 07:11:23 2002 +0000 @@ -1502,16 +1502,18 @@ 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); }
