diff options
| author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 +0000 |
|---|---|---|
| committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 +0000 |
| commit | 1a21451b1d73b65af949193208372e86bf308411 (patch) | |
| tree | 8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/mmapmodule.c | |
| parent | cdf94635d7e364f9ce1905bafa5b540f4d16147c (diff) | |
| download | cpython-git-1a21451b1d73b65af949193208372e86bf308411.tar.gz | |
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/mmapmodule.c')
| -rw-r--r-- | Modules/mmapmodule.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 3600c983b6..51ad69c070 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -1312,24 +1312,37 @@ setint(PyObject *d, const char *name, long value) } } + +static struct PyModuleDef mmapmodule = { + PyModuleDef_HEAD_INIT, + "mmap", + NULL, + -1, + NULL, + NULL, + NULL, + NULL, + NULL +}; + PyMODINIT_FUNC -initmmap(void) +PyInit_mmap(void) { PyObject *dict, *module; if (PyType_Ready(&mmap_object_type) < 0) - return; + return NULL; - module = Py_InitModule("mmap", NULL); + module = PyModule_Create(&mmapmodule); if (module == NULL) - return; + return NULL; dict = PyModule_GetDict(module); if (!dict) - return; + return NULL; mmap_module_error = PyErr_NewException("mmap.error", PyExc_EnvironmentError , NULL); if (mmap_module_error == NULL) - return; + return NULL; PyDict_SetItemString(dict, "error", mmap_module_error); PyDict_SetItemString(dict, "mmap", (PyObject*) &mmap_object_type); #ifdef PROT_EXEC @@ -1366,4 +1379,5 @@ initmmap(void) setint(dict, "ACCESS_READ", ACCESS_READ); setint(dict, "ACCESS_WRITE", ACCESS_WRITE); setint(dict, "ACCESS_COPY", ACCESS_COPY); + return module; } |
