summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Modules/xxmodule.c10
-rw-r--r--Modules/xxsubtype.c14
2 files changed, 12 insertions, 12 deletions
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index 0ee9f7a8ba..3587c91eeb 100644
--- a/Modules/xxmodule.c
+++ b/Modules/xxmodule.c
@@ -231,7 +231,11 @@ initxx(void)
m = Py_InitModule("xx", xx_methods);
/* Add some symbolic constants to the module */
- d = PyModule_GetDict(m);
- ErrorObject = PyErr_NewException("xx.error", NULL, NULL);
- PyDict_SetItemString(d, "error", ErrorObject);
+ if (ErrorObject == NULL) {
+ ErrorObject = PyErr_NewException("xx.error", NULL, NULL);
+ if (ErrorObject == NULL)
+ return;
+ }
+ Py_INCREF(ErrorObject);
+ PyModule_AddObject(d, "error", ErrorObject);
}
diff --git a/Modules/xxsubtype.c b/Modules/xxsubtype.c
index f3d8e89ed7..3b91a0c598 100644
--- a/Modules/xxsubtype.c
+++ b/Modules/xxsubtype.c
@@ -238,7 +238,7 @@ static PyMethodDef xxsubtype_functions[] = {
DL_EXPORT(void)
initxxsubtype(void)
{
- PyObject *m, *d;
+ PyObject *m;
/* Fill in deferred data addresses. This must be done before
PyType_Ready() is called. Note that PyType_Ready() automatically
@@ -263,17 +263,13 @@ initxxsubtype(void)
if (PyType_Ready(&spamdict_type) < 0)
return;
- d = PyModule_GetDict(m);
- if (d == NULL)
- return;
-
Py_INCREF(&spamlist_type);
- if (PyDict_SetItemString(d, "spamlist",
- (PyObject *) &spamlist_type) < 0)
+ if (PyModule_AddObject(m, "spamlist",
+ (PyObject *) &spamlist_type) < 0)
return;
Py_INCREF(&spamdict_type);
- if (PyDict_SetItemString(d, "spamdict",
- (PyObject *) &spamdict_type) < 0)
+ if (PyModule_AddObject(m, "spamdict",
+ (PyObject *) &spamdict_type) < 0)
return;
}