summaryrefslogtreecommitdiff
path: root/Modules/errnomodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 +0000
committerMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 +0000
commit1a21451b1d73b65af949193208372e86bf308411 (patch)
tree8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/errnomodule.c
parentcdf94635d7e364f9ce1905bafa5b540f4d16147c (diff)
downloadcpython-git-1a21451b1d73b65af949193208372e86bf308411.tar.gz
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/errnomodule.c')
-rw-r--r--Modules/errnomodule.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/Modules/errnomodule.c b/Modules/errnomodule.c
index ab4b5f19bd..227e24bdfd 100644
--- a/Modules/errnomodule.c
+++ b/Modules/errnomodule.c
@@ -53,17 +53,29 @@ Symbols that are not relevant to the underlying system are not defined.\n\
To map error codes to error messages, use the function os.strerror(),\n\
e.g. os.strerror(2) could return 'No such file or directory'.");
+static struct PyModuleDef errnomodule = {
+ PyModuleDef_HEAD_INIT,
+ "errno",
+ errno__doc__,
+ -1,
+ errno_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
PyMODINIT_FUNC
-initerrno(void)
+PyInit_errno(void)
{
PyObject *m, *d, *de;
- m = Py_InitModule3("errno", errno_methods, errno__doc__);
+ m = PyModule_Create(&errnomodule);
if (m == NULL)
- return;
+ return NULL;
d = PyModule_GetDict(m);
de = PyDict_New();
if (!d || !de || PyDict_SetItemString(d, "errorcode", de) < 0)
- return;
+ return NULL;
/* Macro so I don't have to edit each and every line below... */
#define inscode(d, ds, de, name, code, comment) _inscode(d, de, name, code)
@@ -786,4 +798,5 @@ initerrno(void)
#endif
Py_DECREF(de);
+ return m;
}