summaryrefslogtreecommitdiffstats
path: root/PC/winreg.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 /PC/winreg.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 'PC/winreg.c')
-rw-r--r--PC/winreg.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/PC/winreg.c b/PC/winreg.c
index 8316f6c..d0397e9 100644
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -1565,23 +1565,36 @@ inskey(PyObject * d, char * name, HKEY key)
#define ADD_KEY(val) inskey(d, #val, val)
-PyMODINIT_FUNC initwinreg(void)
+
+static struct PyModuleDef winregmodule = {
+ PyModuleDef_HEAD_INIT,
+ "winreg",
+ module_doc,
+ -1,
+ winreg_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyMODINIT_FUNC PyInit_winreg(void)
{
PyObject *m, *d;
- m = Py_InitModule3("winreg", winreg_methods, module_doc);
+ m = PyModule_Create(&winregmodule);
if (m == NULL)
- return;
+ return NULL;
d = PyModule_GetDict(m);
Py_TYPE(&PyHKEY_Type) = &PyType_Type;
PyHKEY_Type.tp_doc = PyHKEY_doc;
Py_INCREF(&PyHKEY_Type);
if (PyDict_SetItemString(d, "HKEYType",
(PyObject *)&PyHKEY_Type) != 0)
- return;
+ return NULL;
Py_INCREF(PyExc_WindowsError);
if (PyDict_SetItemString(d, "error",
PyExc_WindowsError) != 0)
- return;
+ return NULL;
/* Add the relevant constants */
ADD_KEY(HKEY_CLASSES_ROOT);
@@ -1640,6 +1653,7 @@ PyMODINIT_FUNC initwinreg(void)
ADD_INT(REG_RESOURCE_LIST);
ADD_INT(REG_FULL_RESOURCE_DESCRIPTOR);
ADD_INT(REG_RESOURCE_REQUIREMENTS_LIST);
+ return m;
}