summaryrefslogtreecommitdiffstats
path: root/Modules/termios.c
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/termios.c
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/termios.c')
-rw-r--r--Modules/termios.c10
1 files changed, 6 insertions, 4 deletions
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);