Skip to content

Commit 9c3c76f

Browse files
author
fdrake
committed
Use the PyModule_Add*() APIs instead of manipulating the module dict
directly. git-svn-id: http://svn.python.org/projects/python/trunk@26091 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 2c095c9 commit 9c3c76f

5 files changed

Lines changed: 280 additions & 283 deletions

File tree

Modules/selectmodule.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -657,34 +657,35 @@ insint(PyObject *d, char *name, int value)
657657
DL_EXPORT(void)
658658
initselect(void)
659659
{
660-
PyObject *m, *d;
660+
PyObject *m;
661661
m = Py_InitModule3("select", select_methods, module_doc);
662-
d = PyModule_GetDict(m);
662+
663663
SelectError = PyErr_NewException("select.error", NULL, NULL);
664-
PyDict_SetItemString(d, "error", SelectError);
664+
Py_INCREF(SelectError);
665+
PyModule_AddObject(m, "error", SelectError);
665666
#ifdef HAVE_POLL
666667
poll_Type.ob_type = &PyType_Type;
667-
insint(d, "POLLIN", POLLIN);
668-
insint(d, "POLLPRI", POLLPRI);
669-
insint(d, "POLLOUT", POLLOUT);
670-
insint(d, "POLLERR", POLLERR);
671-
insint(d, "POLLHUP", POLLHUP);
672-
insint(d, "POLLNVAL", POLLNVAL);
668+
PyModule_AddIntConstant(m, "POLLIN", POLLIN);
669+
PyModule_AddIntConstant(m, "POLLPRI", POLLPRI);
670+
PyModule_AddIntConstant(m, "POLLOUT", POLLOUT);
671+
PyModule_AddIntConstant(m, "POLLERR", POLLERR);
672+
PyModule_AddIntConstant(m, "POLLHUP", POLLHUP);
673+
PyModule_AddIntConstant(m, "POLLNVAL", POLLNVAL);
673674

674675
#ifdef POLLRDNORM
675-
insint(d, "POLLRDNORM", POLLRDNORM);
676+
PyModule_AddIntConstant(m, "POLLRDNORM", POLLRDNORM);
676677
#endif
677678
#ifdef POLLRDBAND
678-
insint(d, "POLLRDBAND", POLLRDBAND);
679+
PyModule_AddIntConstant(m, "POLLRDBAND", POLLRDBAND);
679680
#endif
680681
#ifdef POLLWRNORM
681-
insint(d, "POLLWRNORM", POLLWRNORM);
682+
PyModule_AddIntConstant(m, "POLLWRNORM", POLLWRNORM);
682683
#endif
683684
#ifdef POLLWRBAND
684-
insint(d, "POLLWRBAND", POLLWRBAND);
685+
PyModule_AddIntConstant(m, "POLLWRBAND", POLLWRBAND);
685686
#endif
686687
#ifdef POLLMSG
687-
insint(d, "POLLMSG", POLLMSG);
688+
PyModule_AddIntConstant(m, "POLLMSG", POLLMSG);
688689
#endif
689690
#endif /* HAVE_POLL */
690691
}

0 commit comments

Comments
 (0)