summaryrefslogtreecommitdiffstats
path: root/Modules/errnomodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
commit1a21451b1d73b65af949193208372e86bf308411 (patch)
tree8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/errnomodule.c
parentcdf94635d7e364f9ce1905bafa5b540f4d16147c (diff)
downloadcpython-1a21451b1d73b65af949193208372e86bf308411.zip
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2
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 ab4b5f1..227e24b 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;
}