@@ -989,23 +989,26 @@ PyCreateKey(PyObject *self, PyObject *args)
989989}
990990
991991static PyObject *
992- PyCreateKeyEx (PyObject * self , PyObject * args )
992+ PyCreateKeyEx (PyObject * self , PyObject * args , PyObject * kwargs )
993993{
994994 HKEY hKey ;
995- PyObject * obKey ;
996- wchar_t * subKey ;
995+ PyObject * key ;
996+ wchar_t * sub_key ;
997997 HKEY retKey ;
998- int res = 0 ;
999- REGSAM sam = KEY_WRITE ;
998+ int reserved = 0 ;
999+ REGSAM access = KEY_WRITE ;
10001000 long rc ;
1001- if (!PyArg_ParseTuple (args , "OZ|ii:CreateKeyEx" , & obKey , & subKey ,
1002- & res , & sam ))
1001+
1002+ char * kwlist [] = {"key" , "sub_key" , "reserved" , "access" , NULL };
1003+
1004+ if (!PyArg_ParseTupleAndKeywords (args , kwargs , "OZ|ii:CreateKeyEx" , kwlist ,
1005+ & key , & sub_key , & reserved , & access ))
10031006 return NULL ;
1004- if (!PyHKEY_AsHKEY (obKey , & hKey , FALSE))
1007+ if (!PyHKEY_AsHKEY (key , & hKey , FALSE))
10051008 return NULL ;
10061009
1007- rc = RegCreateKeyExW (hKey , subKey , res , NULL , (DWORD )NULL ,
1008- sam , NULL , & retKey , NULL );
1010+ rc = RegCreateKeyExW (hKey , sub_key , reserved , NULL , (DWORD )NULL ,
1011+ access , NULL , & retKey , NULL );
10091012 if (rc != ERROR_SUCCESS )
10101013 return PyErr_SetFromWindowsErrWithFunction (rc , "CreateKeyEx" );
10111014 return PyHKEY_FromHKEY (retKey );
@@ -1030,22 +1033,23 @@ PyDeleteKey(PyObject *self, PyObject *args)
10301033}
10311034
10321035static PyObject *
1033- PyDeleteKeyEx (PyObject * self , PyObject * args )
1036+ PyDeleteKeyEx (PyObject * self , PyObject * args , PyObject * kwargs )
10341037{
10351038 HKEY hKey ;
1036- PyObject * obKey ;
1039+ PyObject * key ;
10371040 HMODULE hMod ;
10381041 typedef LONG (WINAPI * RDKEFunc )(HKEY , const wchar_t * , REGSAM , int );
10391042 RDKEFunc pfn = NULL ;
1040- wchar_t * subKey ;
1043+ wchar_t * sub_key ;
10411044 long rc ;
1042- int res = 0 ;
1043- REGSAM sam = KEY_WOW64_64KEY ;
1045+ int reserved = 0 ;
1046+ REGSAM access = KEY_WOW64_64KEY ;
10441047
1045- if (!PyArg_ParseTuple (args , "Ou|ii:DeleteKeyEx" ,
1046- & obKey , & subKey , & sam , & res ))
1048+ char * kwlist [] = {"key" , "sub_key" , "access" , "reserved" , NULL };
1049+ if (!PyArg_ParseTupleAndKeywords (args , kwargs , "Ou|ii:DeleteKeyEx" , kwlist ,
1050+ & key , & sub_key , & access , & reserved ))
10471051 return NULL ;
1048- if (!PyHKEY_AsHKEY (obKey , & hKey , FALSE))
1052+ if (!PyHKEY_AsHKEY (key , & hKey , FALSE))
10491053 return NULL ;
10501054
10511055 /* Only available on 64bit platforms, so we must load it
@@ -1060,7 +1064,7 @@ PyDeleteKeyEx(PyObject *self, PyObject *args)
10601064 return NULL ;
10611065 }
10621066 Py_BEGIN_ALLOW_THREADS
1063- rc = (* pfn )(hKey , subKey , sam , res );
1067+ rc = (* pfn )(hKey , sub_key , access , reserved );
10641068 Py_END_ALLOW_THREADS
10651069
10661070 if (rc != ERROR_SUCCESS )
@@ -1282,24 +1286,26 @@ PyLoadKey(PyObject *self, PyObject *args)
12821286}
12831287
12841288static PyObject *
1285- PyOpenKey (PyObject * self , PyObject * args )
1289+ PyOpenKey (PyObject * self , PyObject * args , PyObject * kwargs )
12861290{
12871291 HKEY hKey ;
1288- PyObject * obKey ;
1289-
1290- wchar_t * subKey ;
1291- int res = 0 ;
1292+ PyObject * key ;
1293+ wchar_t * sub_key ;
1294+ int reserved = 0 ;
12921295 HKEY retKey ;
12931296 long rc ;
1294- REGSAM sam = KEY_READ ;
1295- if (!PyArg_ParseTuple (args , "OZ|ii:OpenKey" , & obKey , & subKey ,
1296- & res , & sam ))
1297+ REGSAM access = KEY_READ ;
1298+
1299+ char * kwlist [] = {"key" , "sub_key" , "reserved" , "access" , NULL };
1300+
1301+ if (!PyArg_ParseTupleAndKeywords (args , kwargs , "OZ|ii:OpenKey" , kwlist ,
1302+ & key , & sub_key , & reserved , & access ))
12971303 return NULL ;
1298- if (!PyHKEY_AsHKEY (obKey , & hKey , FALSE))
1304+ if (!PyHKEY_AsHKEY (key , & hKey , FALSE))
12991305 return NULL ;
13001306
13011307 Py_BEGIN_ALLOW_THREADS
1302- rc = RegOpenKeyExW (hKey , subKey , res , sam , & retKey );
1308+ rc = RegOpenKeyExW (hKey , sub_key , reserved , access , & retKey );
13031309 Py_END_ALLOW_THREADS
13041310 if (rc != ERROR_SUCCESS )
13051311 return PyErr_SetFromWindowsErrWithFunction (rc , "RegOpenKeyEx ");
@@ -1667,9 +1673,11 @@ static struct PyMethodDef winreg_methods[] = {
16671673 {"CloseKey" , PyCloseKey , METH_VARARGS , CloseKey_doc },
16681674 {"ConnectRegistry" , PyConnectRegistry , METH_VARARGS , ConnectRegistry_doc },
16691675 {"CreateKey" , PyCreateKey , METH_VARARGS , CreateKey_doc },
1670- {"CreateKeyEx" , PyCreateKeyEx , METH_VARARGS , CreateKeyEx_doc },
1676+ {"CreateKeyEx" , (PyCFunction )PyCreateKeyEx ,
1677+ METH_VARARGS | METH_KEYWORDS , CreateKeyEx_doc },
16711678 {"DeleteKey" , PyDeleteKey , METH_VARARGS , DeleteKey_doc },
1672- {"DeleteKeyEx" , PyDeleteKeyEx , METH_VARARGS , DeleteKeyEx_doc },
1679+ {"DeleteKeyEx" , (PyCFunction )PyDeleteKeyEx ,
1680+ METH_VARARGS | METH_KEYWORDS , DeleteKeyEx_doc },
16731681 {"DeleteValue" , PyDeleteValue , METH_VARARGS , DeleteValue_doc },
16741682 {"DisableReflectionKey" , PyDisableReflectionKey , METH_VARARGS , DisableReflectionKey_doc },
16751683 {"EnableReflectionKey" , PyEnableReflectionKey , METH_VARARGS , EnableReflectionKey_doc },
@@ -1679,8 +1687,10 @@ static struct PyMethodDef winreg_methods[] = {
16791687 ExpandEnvironmentStrings_doc },
16801688 {"FlushKey" , PyFlushKey , METH_VARARGS , FlushKey_doc },
16811689 {"LoadKey" , PyLoadKey , METH_VARARGS , LoadKey_doc },
1682- {"OpenKey" , PyOpenKey , METH_VARARGS , OpenKey_doc },
1683- {"OpenKeyEx" , PyOpenKey , METH_VARARGS , OpenKeyEx_doc },
1690+ {"OpenKey" , (PyCFunction )PyOpenKey , METH_VARARGS | METH_KEYWORDS ,
1691+ OpenKey_doc },
1692+ {"OpenKeyEx" , (PyCFunction )PyOpenKey , METH_VARARGS | METH_KEYWORDS ,
1693+ OpenKeyEx_doc },
16841694 {"QueryValue" , PyQueryValue , METH_VARARGS , QueryValue_doc },
16851695 {"QueryValueEx" , PyQueryValueEx , METH_VARARGS , QueryValueEx_doc },
16861696 {"QueryInfoKey" , PyQueryInfoKey , METH_VARARGS , QueryInfoKey_doc },
0 commit comments