summaryrefslogtreecommitdiffstats
path: root/Modules/xxmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/xxmodule.c')
-rw-r--r--Modules/xxmodule.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Modules/xxmodule.c b/Modules/xxmodule.c
index 0ee9f7a..3587c91 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);
}